Top Level Namespace
Defined Under Namespace
Modules: StudioGame
Classes: BerserkPlayer, Player
Instance Method Summary
collapse
Instance Method Details
#conversation ⇒ Object
2
3
4
5
6
|
# File 'lib/studio_game/iterators.rb', line 2
def conversation
puts "Hello"
yield
puts "Goodbye"
end
|
#fizzbuzz(length) ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/studio_game/rubynotes.rb', line 60
def fizzbuzz(length)
1.upto(length) do |n|
if n % 3 == 0 && n % 5 == 0
puts "FizzBuzz"
elsif n % 5 == 0
puts "Buzz"
elsif n % 3 == 0
puts "Fizz"
else
puts n
end
end
end
|
#gt_five(n) ⇒ Object
32
33
34
|
# File 'lib/studio_game/rubynotes.rb', line 32
def gt_five(n)
n > 5
end
|
#hello(name) ⇒ Object
76
77
78
|
# File 'lib/studio_game/rubynotes.rb', line 76
def hello(name)
puts "Hello there #{name}!"
end
|
#max(n, x) ⇒ Object
46
47
48
|
# File 'lib/studio_game/rubynotes.rb', line 46
def max(n, x)
n > x ? n : x
end
|
#mi_to_km(n) ⇒ Object
39
40
41
|
# File 'lib/studio_game/rubynotes.rb', line 39
def mi_to_km(n)
n * 1.6
end
|
#n_times(number) ⇒ Object
10
11
12
13
14
|
# File 'lib/studio_game/iterators.rb', line 10
def n_times(number)
1.upto(number) do |count|
yield count
end
end
|
#show_triangle(n) ⇒ Object
54
55
56
|
# File 'lib/studio_game/rubynotes.rb', line 54
def show_triangle(n)
1.upto(n) { |length| puts "#" * length }
end
|
#sum(nums) ⇒ Object
120
121
122
|
# File 'lib/studio_game/rubynotes.rb', line 120
def sum(nums)
nums.reduce(0) { |result, n| result + n }
end
|
#three?(n) ⇒ Boolean
25
26
27
|
# File 'lib/studio_game/rubynotes.rb', line 25
def three?(n)
n == 3
end
|