ROMAN_MAX | = | 3999 unless const_defined?(:ROMAN_MAX) | ||
ROMAN_VALUES | = | [ ["M", 1000], ["CM", 900], ["D", 500], ["CD", 400], ["C", 100], ["XC", 90], ["L", 50], ["XL", 40], ["X", 10], ["IX", 9], ["V", 5], ["IV", 4], ["I", 1] |
Is bitmask set?
7.bitmask?(7) #=> true 7.bitmask?(5) #=> true 8.bitmask?(3) #=> false
CREDIT: George Moschovitis
Returns true if this integer is even, false otherwise.
2.even? #=> true 3.even? #=> false
CREDIT: Daniel Schierbeck
Is self a multiple of a given number?
7.multiple?(2) #=> false 8.multiple?(2) #=> true
CREDIT: Trans
Returns true if this integer is odd, false otherwise.
2.odd? #=> false 3.odd? #=> true -99.odd? # -> true -98.odd? # -> false
CREDIT: Daniel Schierbeck
Like times but returns a collection of the yield results.
a = 3.of { |i| "#{i+1}" } a #=> [ "1", "2", "3" ]