Difference between revisions of "Ruby"

From Things and Stuff Wiki
Jump to navigation Jump to search
Line 117: Line 117:
 
== Other ==
 
== Other ==
 
* http://docs.topazruby.com/en/latest/ - ruby on python
 
* http://docs.topazruby.com/en/latest/ - ruby on python
 +
 +
== JavaScript ==
 +
* http://skilldrick.co.uk/2011/01/ruby-vs-javascript-functions-procs-blocks-and-lambdas/
 +
 +
* [http://opalrb.org/ Opal] is a ruby to javascript compiler. It is source-to-source, making it fast as a runtime. Opal includes a compiler (which can be run in any browser), a corelib and runtime implementation. The corelib/runtime is also very small (10.8kb gzipped).
 +
 +
* http://rb2js.rubyforge.org/
 +
 +
* [http://rubyjs.org/ RubyJS] is a JavaScript implementation of all methods from Ruby classes like Array, String, Numbers, Time and more.

Revision as of 18:57, 23 May 2013

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

  • Pry is a powerful alternative to the standard IRB shell for Ruby. It features syntax highlighting, a flexible plugin architecture, runtime invocation and source and documentation browsing.

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

Other

JavaScript

  • Opal is a ruby to javascript compiler. It is source-to-source, making it fast as a runtime. Opal includes a compiler (which can be run in any browser), a corelib and runtime implementation. The corelib/runtime is also very small (10.8kb gzipped).
  • RubyJS is a JavaScript implementation of all methods from Ruby classes like Array, String, Numbers, Time and more.