Class: ISO8601::Months
Overview
A Months atom in a Duration
A “calendar month” is the time interval resulting from the division of a “calendar year” in 12 time intervals.
A “duration month” is the duration of 28, 29, 30 or 31 “calendar days” depending on the start and/or the end of the corresponding time interval within the specific “calendar month”.
Constant Summary collapse
- AVERAGE_FACTOR =
The “duration month” average is calculated through time intervals of 400 “duration years”. Each cycle of 400 “duration years” has 303 “common years” of 365 “calendar days” and 97 “leap years” of 366 “calendar days”.
Years::AVERAGE_FACTOR / 12
Instance Attribute Summary
Attributes included from Atomic
Instance Method Summary collapse
-
#factor(base = nil) ⇒ Numeric
The Month factor.
-
#initialize(atom) ⇒ Months
constructor
A new instance of Months.
-
#symbol ⇒ Symbol
The atom symbol.
-
#to_seconds(base = nil) ⇒ Numeric
The amount of seconds.
Methods included from Atomic
#<=>, #eql?, #hash, #to_f, #to_i, #to_s, #valid_atom?, #valid_base?, #value
Constructor Details
#initialize(atom) ⇒ Months
Returns a new instance of Months.
22 23 24 25 26 |
# File 'lib/iso8601/months.rb', line 22 def initialize(atom) valid_atom?(atom) @atom = atom end |
Instance Method Details
#factor(base = nil) ⇒ Numeric
The Month factor
35 36 37 38 39 40 |
# File 'lib/iso8601/months.rb', line 35 def factor(base = nil) return AVERAGE_FACTOR if base.nil? return calculation(1, base) if atom.zero? calculation(atom, base) end |
#symbol ⇒ Symbol
The atom symbol.
57 58 59 |
# File 'lib/iso8601/months.rb', line 57 def symbol :M end |
#to_seconds(base = nil) ⇒ Numeric
The amount of seconds
49 50 51 |
# File 'lib/iso8601/months.rb', line 49 def to_seconds(base = nil) factor(base) * atom end |