Class: WeatherParameter
- Inherits:
-
Object
- Object
- WeatherParameter
- Defined in:
- lib/weather_parameter.rb
Constant Summary collapse
- DEFAULT_CALCULATION_METHOD =
:mean
Instance Attribute Summary collapse
-
#calculation_method ⇒ Object
Returns the value of attribute calculation_method.
-
#time_layout ⇒ Object
Returns the value of attribute time_layout.
-
#values ⇒ Object
Returns the value of attribute values.
Instance Method Summary collapse
- #[](i) ⇒ Object
-
#initialize(args) ⇒ WeatherParameter
constructor
A new instance of WeatherParameter.
- #value_at(t) ⇒ Object
Constructor Details
#initialize(args) ⇒ WeatherParameter
Returns a new instance of WeatherParameter.
10 11 12 13 14 |
# File 'lib/weather_parameter.rb', line 10 def initialize(args) @time_layout = args[:time_layout] @values = args[:values] @calculation_method = args[:calculation_method] || DEFAULT_CALCULATION_METHOD end |
Instance Attribute Details
#calculation_method ⇒ Object
Returns the value of attribute calculation_method.
6 7 8 |
# File 'lib/weather_parameter.rb', line 6 def calculation_method @calculation_method end |
#time_layout ⇒ Object
Returns the value of attribute time_layout.
6 7 8 |
# File 'lib/weather_parameter.rb', line 6 def time_layout @time_layout end |
#values ⇒ Object
Returns the value of attribute values.
6 7 8 |
# File 'lib/weather_parameter.rb', line 6 def values @values end |
Instance Method Details
#[](i) ⇒ Object
16 17 18 |
# File 'lib/weather_parameter.rb', line 16 def [](i) @values[i] if (@values && @values.is_a?(Array) && i >= 0 && i < @values.length) end |
#value_at(t) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/weather_parameter.rb', line 20 def value_at(t) if t.is_a?(TimeSpan) self.send @calculation_method, t else self[@time_layout.index_at(t)] end end |