Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

110 lines (85 sloc) 2.614 kB
# hashes
{ :one => 'two', 'two three' => 'four', 5 => 'six', "bla bla" => "bla" }
foo = { :bar => 'baz', :one => 'two' }
{ :bar => 'baz', :one => 'two' }
foo = { :bar => { :bazbar => 1 }, :one => { :two => 'three', :four => 'five' }, :five => 'six' }
mail({ :to => 'me', :from => 'me' })
{ :bar => 'baz', :one => 'two' }.merge(:one => 42)
{
:one => { :two => :three },
'one two' => { :two => :three },
"one two" => { :two => :three },
:'one two' => { :two => :three },
:"one two" => { :two => :three }
}
# option hashes:
foo 1, 2, :one => 1, :two => 2, :three => 'three'
class Bar
foo 1, 2, :one => 1, :two => 2, :three => 'three'
end
foo 1, 2, :one => 1, :two => 2, :three => 'three' do
something
end
foo 1, 2, :one => 1, :two => 2, :three => 'three' do |bar|
something(bar)
end
redirect_to root_path, :error => 'ф'
redirect_to root_path, :error => ''
redirect_to root_path, :error => 'f'
mail(:to => 'me', :from => 'me')
mail :to => t('me'), :from => 'me'
foo 1, 2, :bar => 'baz', :one => { :two => 'three', :foo => { 'bar' => 'baz' }, :four => 'five' }, :five => 'six'
foo 1, 2, :bar => 'baz', :one => { :two => 'three', :foo => { 'bar' => 'baz' }, :four => 'five' }
foo 1, 2, :bar => 'baz', :one => { :two => 'three', :foo => { 'bar' => 'baz' }, :four => 'five' } do |one|
two
end
one << two(:three => :four)
three = one + two(:three => :four)
three = one - two(:three => :four)
three = one / two(:three => :four)
three = one * two(:three => :four)
three = one ^ two(:three => :four)
three = one % two(:three => :four)
# hashes with extra whitespace
one = {
:one => 'two',
:three => 'four',
:a => 'b'
}
# option hashes with a single item
root :to => 'articles#index'
# multiple hashes in parameter list
foo 1, 2, { :bar => :baz }, :baz => :qux
foo 1, 2, { :bar => :baz }, { :baz => :qux }
# caching constructs
@two ||= 1 + 1
# other splitting takes precedence
@two ||= lambda { |one| one.two }
@two ||= two(:three => :four, :five => :six)
# blocks
Bar.new { |b| puts b.to_s; puts 'foo' }
Bar.new { puts self.to_s }
Bar.new { foo({ :one => :two, :three => :four }) }
Bar.new { |one| one.new { |two| two.three } }
foo(items.map do |i|
i.bar
end) # comment
foo 'line with do in it' do |something|
something
end
class Baz
def qux
# if/unless/while/until:
return if problem?
return 42 unless something_wrong?
foo 1, 2, :one => 1, :two => 2, :three => 'three' if condition?
foo = "bar" if one.two?
n += 1 while n < 10
n += 1 until n > 10
# multiline if/unless
if one and two
three
four
end
end
end
Jump to Line
Something went wrong with that request. Please try again.