Class: INat::Report::Period
- Inherits:
-
Object
- Object
- INat::Report::Period
- Includes:
- Comparable
- Defined in:
- lib/inat/data/sets/wrappers.rb
Overview
TODO: переделать в модуль namespace и Base-класс отдельно
Defined Under Namespace
Classes: Day, Month, Winter, Year
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(value) ⇒ Period
constructor
A new instance of Period.
Constructor Details
#initialize(value) ⇒ Period
Returns a new instance of Period.
41 42 43 |
# File 'lib/inat/data/sets/wrappers.rb', line 41 def initialize value @value = value end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
39 40 41 |
# File 'lib/inat/data/sets/wrappers.rb', line 39 def value @value end |
Class Method Details
.[](src) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/inat/data/sets/wrappers.rb', line 15 def [] src return nil if src == nil return src if self === src value = case src when Date self.date_to_value src when Time self.date_to_value src.to_date when String date = Date::parse src self.date_to_value date when Integer src else raise TypeError, "Invalid date: #{ src.inspect }", caller end return nil if value == nil @values ||= {} @values[value] ||= new value @values[value] end |
Instance Method Details
#<=>(other) ⇒ Object
47 48 49 50 |
# File 'lib/inat/data/sets/wrappers.rb', line 47 def <=> other return nil unless self.class === other @value <=> other.value end |