Class: Integer

Inherits:
Object
  • Object
show all
Defined in:
lib/finance/interval.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Integer

convert an integer value representing months (or years) into months

Examples:

360.months #=> 360
30.years #=> 360

Returns:

  • (Integer)

    the number of months



8
9
10
11
12
# File 'lib/finance/interval.rb', line 8

def method_missing(name, *args, &block)
  return self      if name.to_s == "months"
  return self * 12 if name.to_s == "years"
  super
end