Class: WeatherGov::ValidDurationValue
- Inherits:
-
Object
- Object
- WeatherGov::ValidDurationValue
- Defined in:
- lib/weather_gov/valid_duration_value.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#unit ⇒ Object
readonly
Returns the value of attribute unit.
Instance Method Summary collapse
-
#initialize(data:, unit: nil) ⇒ ValidDurationValue
constructor
A new instance of ValidDurationValue.
- #valid? ⇒ Boolean
- #valid_time ⇒ Object
- #value ⇒ Object
Constructor Details
#initialize(data:, unit: nil) ⇒ ValidDurationValue
Returns a new instance of ValidDurationValue.
9 10 11 12 |
# File 'lib/weather_gov/valid_duration_value.rb', line 9 def initialize(data:, unit: nil) @data = data @unit = unit end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
7 8 9 |
# File 'lib/weather_gov/valid_duration_value.rb', line 7 def data @data end |
#unit ⇒ Object (readonly)
Returns the value of attribute unit.
7 8 9 |
# File 'lib/weather_gov/valid_duration_value.rb', line 7 def unit @unit end |
Instance Method Details
#valid? ⇒ Boolean
18 19 20 |
# File 'lib/weather_gov/valid_duration_value.rb', line 18 def valid? valid_time.valid? end |
#valid_time ⇒ Object
14 15 16 |
# File 'lib/weather_gov/valid_duration_value.rb', line 14 def valid_time @valid_time ||= ValidTime.new(data.fetch("validTime")) end |
#value ⇒ Object
22 23 24 |
# File 'lib/weather_gov/valid_duration_value.rb', line 22 def value @value ||= data.fetch("value") end |