Module: Fish
- Defined in:
- lib/Fish.rb,
lib/Fish/version.rb
Constant Summary collapse
- VERSION =
'0.0.3'
Class Method Summary collapse
- .fish(len = 3, looks_right = true) ⇒ Object
- .is_fish?(str) ⇒ Boolean
- .many_fish(num, len = 3, looks_right = true) ⇒ Object
- .many_random_fish(num, max_len = 10) ⇒ Object
- .random_fish(max_len = 10) ⇒ Object
Class Method Details
.fish(len = 3, looks_right = true) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/Fish.rb', line 4 def self.fish(len = 3, looks_right = true) if looks_right "><#{'(' * len}°>" else "<°#{')' * len}><" end end |
.is_fish?(str) ⇒ Boolean
18 19 20 21 22 23 |
# File 'lib/Fish.rb', line 18 def self.is_fish?(str) ret = false ret = true if str.match(/><\(+°>/) != nil ret = true if str.match(/<°\)+></) != nil return ret end |
.many_fish(num, len = 3, looks_right = true) ⇒ Object
12 13 14 15 16 |
# File 'lib/Fish.rb', line 12 def self.many_fish(num, len = 3, looks_right = true) a = [] num.times {a << fish(len, looks_right)} return a end |
.many_random_fish(num, max_len = 10) ⇒ Object
29 30 31 32 33 |
# File 'lib/Fish.rb', line 29 def self.many_random_fish(num, max_len = 10) a = [] num.times {a << random_fish(max_len)} return a end |
.random_fish(max_len = 10) ⇒ Object
25 26 27 |
# File 'lib/Fish.rb', line 25 def self.random_fish(max_len = 10) fish(1 + rand(max_len), rand(2) == 1) end |