![ruby](img/ruby-logo-R.png)
#Warum?
> "I wanted a scripting language that was more powerful than Perl, and more object-oriented than Python. That's why I decided to design my own language." (Yokihiro "Matz" Matsumoto)
> "I hope to see Ruby help every programmer in the world to be productive, and to enjoy programming, and to be happy. That is the primary purpose of Ruby language." (Yokihiro "Matz" Matsumoto)
#Wie?
- Perl String Features - Perl Syntax minus Gekröse - Smalltalk Type System - Lisp Closures, anonyme Funktionen
# Features
- interpretiert - Garbage-collected - objektorientiert - dynamisch typisiert - offene Klassen - alles ist ein Ausdruck - Closures - Continuations - mehrere Character-Encodings - benannte Argumente - nur false und nil sind nicht true-ish
# Syntax
- keine Semicolons am Zeilenende - Klammern nur, wo nötig - Implizites Return-Statement - Literale für Hash, Array, Range, Regexp, Wort-Array, Symbol-Array - Yoda-Code

Beispiele


puts -199.abs                              #=> 199
puts 'Chunky Bacon!'.length                #=> 13
puts 'ruby is cool.'.index 'u'             #=> 1
puts %q{Nice Day Isn't It?}.downcase.split('').uniq.sort.join
                                            #=> ' ?acdeinsty
            

class Fixnum
  def + other
    self - other
  end
end

p 5 + 3  #=> 2
p 5.+(3) #=> 2
            
![ruby](img/one_foot.jpg)
![ruby](img/two_feet.jpg)

def foo
  'klar!'
end

if a = foo
  puts a
end

b = if true
  'natürlich!'
end

puts b
puts 'klar' if true
            

(1..100).each do |i|
  puts i
end
            

def double &block
  block.call
  block.call
end

double do
  puts 'Hi!'   #=> Hi!
end            #=> Hi!
            

describe MySum do
  it "performs a sum" do
    sum = MyClass.add 1, 1
    sum.should == 2
  end
end
            

require 'sinatra'

get '/hi' do
  'Hello World!'
end
          

doc 'The schedule of a single station grouped by playlists.'
doc :example, 'http://HOSTNAME/station/deepgroove/playlists'
doc :parameters, {station_name: '[\w\d_\-]+'}
doc :key, '/station/{station_name}/playlists'
get %r{\A/station/([\w\d_\-]+)/playlists\Z} do |name|
  expires schedule_expiration, :public, :must_revalidate
  RedisStore::Playlists.find(name)
end
            
##Implementierungen - [YARV (Ruby 1.9/2.0)](http://www.ruby-lang.org/) - MRI (Ruby 1.8) - [jRuby](http://jruby.org/) - [Rubinius](http://rubini.us/) - [MacRuby (Obj. C)](http://macruby.org/) - [Iron Ruby (.Net)](http://www.ironruby.net/) - [Maglev (GemStone VM)](http://maglev.github.io/) - [mRuby (Lightweight Ruby)](https://github.com/mruby/mruby) - [Topaz (PyPy VM)](http://docs.topazruby.com/en/latest/)
![ruby](img/gems.jpg) #Ruby-Gems
##Kommandos - `gem install GEMNAME` - `gem list` - `gem build GEMSPEC` - `gem push GEMFILE`
![ruby](img/rake.jpg) #Rake
##Rakefile task default: :test desc 'Run all the tests' task :test do ruby "test/unittest.rb" end
##Methoden - `task` - `file` - `directory` - `namespace` - `multitask`
##Kommandos - `rake` - `rake TASKNAME` - `rake -T`
![ruby](img/bundle.jpg) #Bundler
##Gemfile source 'http://rubygems.org' gem 'sinatra', '~> 0.9.0' gem 'rack-cache' gem 'rack-bug' gem 'lautfm_utils', '>= 0.0.23', path: '/Users/niko/laut/lautfm_utils' gem 'ad_machine', '>= 0.2.9', :git => 'git@github.com:lautde/ad_machine.git'
##Bundler Kommandos - `bundle install` - `bundle update GEMNAME` - `bundle pack` - `bundle install --deployment`
![ruby](img/capestrano.jpg) #Capistrano
##Capistrano Kommandos - `cap -T` - `cap deploy`
##Capfile set :application, 'www' set :deploy_to, '/export/webroot/www' set :user, 'laut' set :scm, :git set :repository, 'git@github.com:lautde/laut.fm-V2.git' set :branch, 'master' namespace :deploy do task :restart_daemons, roles: :web do ... end after 'deploy', 'deploy:restart_daemons' end
![ruby](img/rubber_duck.jpg) #RVM
##RVM Kommandos - `curl -L https://get.rvm.io | bash` - `rvm install 2.0.0` - `rvm use 2.0.0 --default` - `rvm use 1.9.3-p285` - `rvm use jruby` - `rvm install [jruby|rbx|maglev|ironruby|macruby]`
![ruby](img/rotten.jpg) ##The bad, the ugly
- Geschwindigkeit - Concurrency Model - Semantic Versioning - Installation - Tooling
##Gotchas - Monkey Patching - $!, $&, $+ - and or & || precedence - Regex ^...$ vs. \A...\z - == === #eql? #equal? - super vs. super() - 1/2 != 0.5
##Links - http://blog.niko-dittmann.com/ruby_presentation_sdc_2013 - [Ruby Homepage](http://www.ruby-lang.org/) - [Ruby Dokumentation](http://www.ruby-lang.org/en/documentation/) - [Ruby auf en.wikipedia.org](http://en.wikipedia.org/wiki/Ruby_(programming_language) - [Try Ruby](http://tryruby.org) - [Ruby Best Practices Book PDF](http://blog.rubybestpractices.com/posts/gregory/022-rbp-now-open.html) - [_why's poignant guide to Ruby](http://mislav.uniqpath.com/poignant-guide/) - [Ruby is an acceptable Lisp](http://www.randomhacks.net/articles/2005/12/03/why-ruby-is-an-acceptable-lisp) - [Rubygems Homepage](http://rubygems.org/) - [Ruby Toolbox](https://www.ruby-toolbox.com/) - [Rake Homepage](http://rake.rubyforge.org/) - [Rake Präsentation](http://de.slideshare.net/filmprog/rake-not-your-fathers-build-tool) - [Bundler Homepage](http://gembundler.com/) - [Capistrano Homepage](http://capistranorb.com/) - [Capistrano Walkthrough](http://guides.beanstalkapp.com/deployments/deploy-with-capistrano.html) - [RVM Homepage](https://rvm.io/) - [Spinning Earth Ruby Quine](http://mamememo.blogspot.de/2010/09/qlobe.html)
##Img Credits - http://www.flickr.com/photos/19684903@N00/317182464 (rake) - http://www.flickr.com/photos/ludaarce/1056521098 (gems) - http://www.flickr.com/photos/warmestregards/617232144 (bundle) - http://www.flickr.com/photos/chrisschoenbohm/5257019973 (capestrano) - http://www.flickr.com/photos/joeshlabotnik/1721746230 (rotten)