Class: WeatherGov::ValidDurationValue

Inherits:
Object
  • Object
show all
Defined in:
lib/weather_gov/valid_duration_value.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#dataObject (readonly)

Returns the value of attribute data.



7
8
9
# File 'lib/weather_gov/valid_duration_value.rb', line 7

def data
  @data
end

#unitObject (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

Returns:

  • (Boolean)


18
19
20
# File 'lib/weather_gov/valid_duration_value.rb', line 18

def valid?
  valid_time.valid?
end

#valid_timeObject



14
15
16
# File 'lib/weather_gov/valid_duration_value.rb', line 14

def valid_time
  @valid_time ||= ValidTime.new(data.fetch("validTime"))
end

#valueObject



22
23
24
# File 'lib/weather_gov/valid_duration_value.rb', line 22

def value
  @value ||= data.fetch("value")
end