Class: KNMI::Parameters
- Inherits:
-
Object
- Object
- KNMI::Parameters
- Defined in:
- lib/knmi/parameters.rb
Class Attribute Summary collapse
-
.keys_file ⇒ Object
writeonly
Sets the attribute keys_file.
Instance Attribute Summary collapse
-
#category ⇒ String
readonly
-
Categories grouping parameters.
-
-
#conversion ⇒ String
readonly
-
example code to convert data into appropriate format/units for operation.
-
-
#description ⇒ String
readonly
-
Description of parameter.
-
-
#parameter ⇒ String
readonly
-
Paramter shortname.
-
-
#period ⇒ String
readonly
-
Time Period “daily” or “hourly”.
-
-
#units ⇒ String
readonly
-
Unit of converted format.
-
-
#validate ⇒ String
readonly
-
example code to validate data as accurate.
-
Class Method Summary collapse
-
.all(period) ⇒ Array<KNMI::Parameters>
Retrieve all Parameters.
-
.category(period, category) ⇒ Array<KNMI::Parameters>
Retrieve Parameter Object by named parameter.
-
.find(period, parameter) ⇒ Array<KNMI::Parameters>
Retrieve Parameter Object by named parameter.
Instance Method Summary collapse
-
#detail ⇒ Hash
-
Hash containing important details about parameters object.
-
-
#initialize(properties) ⇒ Parameters
constructor
A new instance of Parameters.
Constructor Details
#initialize(properties) ⇒ Parameters
Returns a new instance of Parameters.
95 96 97 98 99 |
# File 'lib/knmi/parameters.rb', line 95 def initialize(properties) @parameter, @category, @description, @validate, @conversion, @units, @period = %w(parameter category description validate conversion units period).map do |p| properties[p] end end |
Class Attribute Details
.keys_file=(value) ⇒ Object
Sets the attribute keys_file
4 5 6 |
# File 'lib/knmi/parameters.rb', line 4 def keys_file=(value) @keys_file = value end |
Instance Attribute Details
#category ⇒ String (readonly)
Returns - Categories grouping parameters.
78 79 80 |
# File 'lib/knmi/parameters.rb', line 78 def category @category end |
#conversion ⇒ String (readonly)
Returns - example code to convert data into appropriate format/units for operation.
87 88 89 |
# File 'lib/knmi/parameters.rb', line 87 def conversion @conversion end |
#description ⇒ String (readonly)
Returns - Description of parameter.
81 82 83 |
# File 'lib/knmi/parameters.rb', line 81 def description @description end |
#parameter ⇒ String (readonly)
Returns - Paramter shortname.
75 76 77 |
# File 'lib/knmi/parameters.rb', line 75 def parameter @parameter end |
#period ⇒ String (readonly)
Returns - Time Period “daily” or “hourly”.
93 94 95 |
# File 'lib/knmi/parameters.rb', line 93 def period @period end |
#units ⇒ String (readonly)
Returns - Unit of converted format.
90 91 92 |
# File 'lib/knmi/parameters.rb', line 90 def units @units end |
#validate ⇒ String (readonly)
Returns - example code to validate data as accurate.
84 85 86 |
# File 'lib/knmi/parameters.rb', line 84 def validate @validate end |
Class Method Details
.all(period) ⇒ Array<KNMI::Parameters>
Retrieve all Parameters
52 53 54 55 56 |
# File 'lib/knmi/parameters.rb', line 52 def all(period) list = [] list << keys.select { |k| k.period == period } list.flatten! end |
.category(period, category) ⇒ Array<KNMI::Parameters>
Retrieve Parameter Object by named parameter
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/knmi/parameters.rb', line 37 def category(period, category) category = [category].flatten list = [] category.uniq.each do |c| list << keys.select { |k| k.category == c and k.period == period } end return list.flatten! end |
.find(period, parameter) ⇒ Array<KNMI::Parameters>
Retrieve Parameter Object by named parameter
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/knmi/parameters.rb', line 16 def find(period, parameter) parameter = [parameter].flatten list = [] parameter.uniq.each do |p| list << keys.find { |k| k.parameter == p and k.period == period } end return list end |
Instance Method Details
#detail ⇒ Hash
Returns - Hash containing important details about parameters object.
102 103 104 105 106 |
# File 'lib/knmi/parameters.rb', line 102 def detail {:parameter => @parameter, :category => @category, :description => @description, :validate => @validate, :conversion => @conversion, :units => @units, :period => @period} end |