Class: Sekki24::Kou
Constant Summary collapse
- ATTRIBUTES =
%i[ordinal name_ja reading longitude term_key position time].freeze
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(definition:, time:) ⇒ Kou
constructor
A new instance of Kou.
- #inspect ⇒ Object
- #to_date ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(definition:, time:) ⇒ Kou
Returns a new instance of Kou.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/sekki24/kou.rb', line 11 def initialize(definition:, time:) @ordinal = definition.ordinal @name_ja = definition.name_ja @reading = definition.reading @longitude = definition.longitude @term_key = definition.term_key @position = definition.position @time = time.dup.freeze freeze end |
Instance Method Details
#<=>(other) ⇒ Object
22 23 24 25 26 |
# File 'lib/sekki24/kou.rb', line 22 def <=>(other) return unless other.respond_to?(:time) time <=> other.time end |
#==(other) ⇒ Object Also known as: eql?
28 29 30 |
# File 'lib/sekki24/kou.rb', line 28 def ==(other) other.is_a?(Kou) && ordinal == other.ordinal && time == other.time end |
#hash ⇒ Object
33 34 35 |
# File 'lib/sekki24/kou.rb', line 33 def hash [self.class, ordinal, time].hash end |
#inspect ⇒ Object
45 46 47 |
# File 'lib/sekki24/kou.rb', line 45 def inspect "#<#{self.class} 第#{ordinal}候 #{name_ja} #{time.iso8601} longitude=#{longitude}°>" end |
#to_date ⇒ Object
37 38 39 |
# File 'lib/sekki24/kou.rb', line 37 def to_date time.to_date end |
#to_h ⇒ Object
41 42 43 |
# File 'lib/sekki24/kou.rb', line 41 def to_h ATTRIBUTES.to_h { |attribute| [attribute, public_send(attribute)] } end |