background preloader

Ruby

Ruby
Related:  Ruby

What is the difference between require_relative and require in Ruby? Data on Rails - Google Data Protocol - Google Code Eric Bidelman, Google Data APIs Team February 2009 Contents Introduction "Where's Ruby on the list of client libraries?" Motivated by the ferocious appetite of our developers and the enduring popularity of Ruby on Rails (RoR), my colleague Jeff Fisher has forged a Ruby utility library from the fiery depths of Mount Doom. Mind you, it's not a full-blown client library, but it does handle the fundamentals like authentication and basic XML manipulation. Audience This article is intended for developers interested in accessing the Google Data APIs using Ruby, specifically Ruby on Rails. Getting Started Requirements Ruby 1.8.6 patch level 114+ downloadRubyGems 1.3.1+ downloadRails 2.2.2+ download Installing the Google Data Ruby Utility Library To obtain the library, you can either download the library source directly from project hosting or install the gem: sudo gem install gdata Tip: For good measure, run gem list --local to verify that the gem was installed properly. Authentication ClientLogin AuthSub #!

Ruby Historique[modifier | modifier le code] Depuis l'arrivée d'une documentation anglophone, et du framework web Ruby on Rails en 2004, Ruby a connu un certain engouement qui n'a cessé de croître jusqu'en 2008 dans le monde de la programmation, puis une érosion lente si on en juge par son index Tiobe. Philosophie[modifier | modifier le code] Ruby est fortement orienté objet et se rapproche ainsi du paradigme objet de Smalltalk[note 1] : Fonctionnalités[modifier | modifier le code] Les fonctionnalités principales sont : Implémentations[modifier | modifier le code] Ruby est fourni avec irb, un interpréteur de commandes interactif pour tester en profondeur le fonctionnement du langage. Depuis le 1er janvier 2007, le développement de Ruby (1.9) est basé sur l'interpréteur YARV écrit par Koichi Sasada[10]. Outre YARV, il existe plusieurs autres interpréteurs Ruby[11] : La version 2.0 permet de créer des applications graphiques pour macOS et iOS. Interprètes embarqués[modifier | modifier le code]

John Ewart In Ruby, interfaces are not really a part of the programming paradigm. By its very nature, Ruby is designed to be flexible and loosely-typed, and that provides developers with a lot of power. Over the years I’ve seen a number of projects that are written in Ruby become internally inconsistent. What I mean by this is that developers decide that their abstractions or structure isn’t working and instead of working from the bottom up, just start writing modifications to make things work. Take, for example, Fog.io, which I mentioned in a previous post. Just because Ruby does not formally support interfaces in the same way Java or C# do, doesn’t mean that it is impossible to maintain a set of interfaces in your code and ensure that developers are adhering to those interfaces. Take for example, some code in Ruby that looks like this: An example interface in Ruby class FunctionalInterface def do_thing raise "This is not implemented!"

showing google calendar events in rails view Lancez-vous dans la programmation avec Ruby Ce cours est destiné à tous les curieux qui souhaitent s’initier à la programmation, et aux codeurs qui souhaitent apprendre un nouveau langage. Ici, vous allez découvrir Ruby, un langage de programmation qui a été créé par un informaticien japonais dans les années 1990, avec un objectif en tête : faciliter la vie des développeurs avec une syntaxe et des outils simples et agréables à utiliser. Que vous ayez des connaissances en programmation ou pas, vous pouvez suivre ce cours où vous apprendrez à manipuler les outils de base de Ruby ainsi que ses puissants "objets". Une fois que vous maîtriserez ces notions, vous aurez toutes les cartes en main pour aller plus loin et réaliser vos propres projets, comme par exemple :

Ruby Exceptions Raising An Exception An exception is a special kind of object, an instance of the class Exception or a descendant of that class that represents some kind of exceptional condition; it indicates that something has gone wrong. When this occurs, an exception is raised (or thrown). By default, Ruby programs terminate when an exception occurs. But it is possible to declare exception handlers. An exception handler is a block of code that is executed if an exception occurs during the execution of some other block of code. Ruby has some predefined classes - Exception and its children - that help you to handle errors that can occur in your program. Reference: The above figure is from the Programming Ruby book. The chart above shows that most of the subclasses extend a class known as StandardError. The following method raises an exception whenever it's called. def raise_exception puts 'I am before the raise.' The output is: The raise method is from the Kernel module. Handling an Exception

Ruby sample code | Viadeo API You can find below a sample code implementing OAuth2 and an access to the ‘/me’ endpoint. The script will redirects you to the Viadeo OAuth2 authentication page, just enter some Viadeo credentials and you will be redirected to ‘ with the accesss_token set. This samples runs with Ruby 1.8 + Rails 2.3.4. Note: Error catching is here minimal, you have to implement a better error management.

Club des développeurs Ruby et Ruby on Rails : actualités, cours, tutoriels, programmation, codes sources, livres, outils et forums DPiR | Companion site to Russ Olsen's book Full text search in in Rails with Sunspot and Solr « TechBot The book you should get to dig deeper into Solr Click here if you want to see a PDF version of this tutorial. Full source code for this tutorial is available at GitHub. Everyone wants to take their databases to run everything as fast as possible. When querying for text in our databases, we’re often doing “LIKE” searches. The database would be able to optimize this query and use the index to find the expected row. Your DBA getting ready to hit you Database indexes usually match from left to right, so, unless you have a nasty trick under your sleeve, this query will just look at ALL the rows in the products table and perform a match on every “name” column before returning a result. That’s where full text search based solutions come in for help. In this tutorial you’ll learn how to add full text searching capabilities to your Rails application using Sunpot and Solr. The source code for this example application is available at GitHub here . Starting the engines Listing 1 – sunspot.yml Searching

Related: