Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/mani_zanec_math/array/foobar.rb,
lib/mani_zanec_math/array/arithmetic_progression.rb
Instance Method Summary collapse
Instance Method Details
#arithmetic_progression? ⇒ Boolean
2 3 4 5 |
# File 'lib/mani_zanec_math/array/arithmetic_progression.rb', line 2 def arithmetic_progression? return true if size < 2 (self.first..self.last).step((self.last-self.first)/(self.size-1)).to_a == self end |
#foobar ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/mani_zanec_math/array/foobar.rb', line 2 def arr = [] self.each{|x| if (x.modulo(3) == 0 && x.modulo(5) == 0) arr.push("foobar") elsif (x.modulo(5) == 0) arr.push("bar") elsif (x.modulo(3) == 0 && x.modulo(2) != 0) arr.push("foo") else arr.push(nil) end } return arr end |