Class: Relaton::Bib::StringDate::Value
- Inherits:
-
Object
- Object
- Relaton::Bib::StringDate::Value
- Extended by:
- Core::DateParser, Forwardable
- Includes:
- Comparable, Core::DateParser
- Defined in:
- lib/relaton/bib/model/type/string_date.rb
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(value) ⇒ Value
constructor
A new instance of Value.
- #to_date ⇒ Object
Constructor Details
#initialize(value) ⇒ Value
Returns a new instance of Value.
14 15 16 |
# File 'lib/relaton/bib/model/type/string_date.rb', line 14 def initialize(value) @value = value end |
Class Method Details
.parse_date(date) ⇒ Object
18 19 20 21 |
# File 'lib/relaton/bib/model/type/string_date.rb', line 18 def self.parse_date(date) value = super new value if value end |
Instance Method Details
#<=>(other) ⇒ Object
23 24 25 26 27 |
# File 'lib/relaton/bib/model/type/string_date.rb', line 23 def <=>(other) return nil unless other.is_a?(Value) @value <=> other.to_s end |
#to_date ⇒ Object
29 30 31 32 33 |
# File 'lib/relaton/bib/model/type/string_date.rb', line 29 def to_date parse_date(@value, str: false) rescue ArgumentError nil end |