Ruby

From Things and Stuff Wiki
Revision as of 05:13, 30 October 2012 by Milk (talk | contribs) (→‎Guides)
Jump to navigation Jump to search


Basics

  • Ruby is a dynamic, open source programming language with a focus on simplicity and productivity. It has an elegant syntax that is natural to read and easy to write.
# The Greeter class
class Greeter
  def initialize(name)
    @name = name.capitalize
  end
 
  def salute
    puts "Hello #{@name}!"
  end
end
 
# Create a new object
g = Greeter.new("world")
 
# Output "Hello World!"
g.salute

Guides

Gems

Guides

  • isitruby1.9 Community-powered gem compatibility for ruby 1.9]

Setup

install ruby rubygems

Installing Gems

gem install [rubygem]
  install a gem
gem upgrade
  upgrade installed gems
gem env

As user, goes into .gem. As root, goes into /usr/lib/ruby/gems/1.9.1/gems/compass-0.11.7/frameworks/compass/stylesheets/compass or suchlike.

ruby -r rubygems -e "p Gem.path"   
  display ruby gem path[s]

to sort

Tools

Shoes

Development

  • jim - jim is your friendly javascript library manager. He downloads, stores, bundles, vendors and compresses.

Sinatra

require 'sinatra'

get '/hi' do
  "Hello World!"
end
gem install sinatra
ruby hi.rb

CMS/F

Mobile apps