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