Class: JMACode::PointAmedas::Snow
- Inherits:
-
Struct
- Object
- Struct
- JMACode::PointAmedas::Snow
- Defined in:
- lib/jma_code/point_amedas.rb
Constant Summary collapse
- HEADERS =
i( government_branch_name code type name name_phonetic location lat_major lat_minor lng_major lng_minor altitude observation_started_since )
Instance Attribute Summary collapse
-
#altitude ⇒ Object
Returns the value of attribute altitude.
-
#code ⇒ Object
Returns the value of attribute code.
-
#government_branch_name ⇒ Object
Returns the value of attribute government_branch_name.
-
#lat ⇒ Object
Returns the value of attribute lat.
-
#lng ⇒ Object
Returns the value of attribute lng.
-
#location ⇒ Object
Returns the value of attribute location.
-
#name ⇒ Object
Returns the value of attribute name.
-
#name_phonetic ⇒ Object
Returns the value of attribute name_phonetic.
-
#observation_started_since ⇒ Object
Returns the value of attribute observation_started_since.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
Instance Attribute Details
#altitude ⇒ Object
Returns the value of attribute altitude
76 77 78 |
# File 'lib/jma_code/point_amedas.rb', line 76 def altitude @altitude end |
#code ⇒ Object
Returns the value of attribute code
76 77 78 |
# File 'lib/jma_code/point_amedas.rb', line 76 def code @code end |
#government_branch_name ⇒ Object
Returns the value of attribute government_branch_name
76 77 78 |
# File 'lib/jma_code/point_amedas.rb', line 76 def government_branch_name @government_branch_name end |
#lat ⇒ Object
Returns the value of attribute lat
76 77 78 |
# File 'lib/jma_code/point_amedas.rb', line 76 def lat @lat end |
#lng ⇒ Object
Returns the value of attribute lng
76 77 78 |
# File 'lib/jma_code/point_amedas.rb', line 76 def lng @lng end |
#location ⇒ Object
Returns the value of attribute location
76 77 78 |
# File 'lib/jma_code/point_amedas.rb', line 76 def location @location end |
#name ⇒ Object
Returns the value of attribute name
76 77 78 |
# File 'lib/jma_code/point_amedas.rb', line 76 def name @name end |
#name_phonetic ⇒ Object
Returns the value of attribute name_phonetic
76 77 78 |
# File 'lib/jma_code/point_amedas.rb', line 76 def name_phonetic @name_phonetic end |
#observation_started_since ⇒ Object
Returns the value of attribute observation_started_since
76 77 78 |
# File 'lib/jma_code/point_amedas.rb', line 76 def observation_started_since @observation_started_since end |
#type ⇒ Object
Returns the value of attribute type
76 77 78 |
# File 'lib/jma_code/point_amedas.rb', line 76 def type @type end |
Class Method Details
.build_by_csv_row(row) ⇒ Object
118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/jma_code/point_amedas.rb', line 118 def build_by_csv_row(row) new( code: row[:code], name: row[:name], name_phonetic: row[:name_phonetic], government_branch_name: row[:government_branch_name], type: row[:type], location: row[:location], lat: "#{row[:lat_major]}.#{row[:lat_minor]}".to_f, lng: "#{row[:lng_major]}.#{row[:lng_minor]}".to_f, altitude: row[:altitude], observation_started_since: row[:observation_started_since], ) end |
.load(csv, num_headers: 2) ⇒ Object
109 110 111 112 113 114 115 116 |
# File 'lib/jma_code/point_amedas.rb', line 109 def load(csv, num_headers: 2) list = [] csv.each.with_index do |row, i| next if i < num_headers list << build_by_csv_row(row) end list end |
.load_20240325(&block) ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/jma_code/point_amedas.rb', line 97 def load_20240325(&block) path = File.join(File.dirname(__FILE__), "../../data/20240325_PointAmedas/snow_master.csv") File.open(path) do |f| csv = CSV.new(f, headers: HEADERS, row_sep: "\r\n") if block_given? yield(csv) else load(csv, num_headers: 2, &block) end end end |