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