Module: Kernel
- Defined in:
- lib/monthify/month.rb
Instance Method Summary collapse
-
#Month(object_to_convert) ⇒ Month
Globally accessible method to convert an argument into a Month.
Instance Method Details
#Month(object_to_convert) ⇒ Month
Globally accessible method to convert an argument into a Month. If the argument cannot be converted, it raises an ArgumentError
143 144 145 146 147 148 149 150 151 |
# File 'lib/monthify/month.rb', line 143 def Month(object_to_convert) if object_to_convert.is_a?(Month) object_to_convert elsif object_to_convert.respond_to?(:to_date) Month.containing(object_to_convert.to_date) else raise ArgumentError, "Don't know how to convert #{object_to_convert.inspect} to Month" end end |