Class: JMACode::PointAmedas::Ame
- Inherits:
-
Struct
- Object
- Struct
- JMACode::PointAmedas::Ame
- 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 altitude_anemometer altitude_thermometer observation_started_since memo1 memo2 )
Instance Attribute Summary collapse
-
#altitude ⇒ Object
Returns the value of attribute altitude.
-
#altitude_anemometer ⇒ Object
Returns the value of attribute altitude_anemometer.
-
#altitude_thermometer ⇒ Object
Returns the value of attribute altitude_thermometer.
-
#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.
-
#managed_by ⇒ Object
Returns the value of attribute managed_by.
-
#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
- .build_by_csv_row(row, managed_by: nil) ⇒ Object
- .load(csv, num_headers: 2) ⇒ Object
- .load_20240325(&block) ⇒ Object
Instance Attribute Details
#altitude ⇒ Object
Returns the value of attribute altitude
4 5 6 |
# File 'lib/jma_code/point_amedas.rb', line 4 def altitude @altitude end |
#altitude_anemometer ⇒ Object
Returns the value of attribute altitude_anemometer
4 5 6 |
# File 'lib/jma_code/point_amedas.rb', line 4 def altitude_anemometer @altitude_anemometer end |
#altitude_thermometer ⇒ Object
Returns the value of attribute altitude_thermometer
4 5 6 |
# File 'lib/jma_code/point_amedas.rb', line 4 def altitude_thermometer @altitude_thermometer end |
#code ⇒ Object
Returns the value of attribute code
4 5 6 |
# File 'lib/jma_code/point_amedas.rb', line 4 def code @code end |
#government_branch_name ⇒ Object
Returns the value of attribute government_branch_name
4 5 6 |
# File 'lib/jma_code/point_amedas.rb', line 4 def government_branch_name @government_branch_name end |
#lat ⇒ Object
Returns the value of attribute lat
4 5 6 |
# File 'lib/jma_code/point_amedas.rb', line 4 def lat @lat end |
#lng ⇒ Object
Returns the value of attribute lng
4 5 6 |
# File 'lib/jma_code/point_amedas.rb', line 4 def lng @lng end |
#location ⇒ Object
Returns the value of attribute location
4 5 6 |
# File 'lib/jma_code/point_amedas.rb', line 4 def location @location end |
#managed_by ⇒ Object
Returns the value of attribute managed_by
4 5 6 |
# File 'lib/jma_code/point_amedas.rb', line 4 def managed_by @managed_by end |
#name ⇒ Object
Returns the value of attribute name
4 5 6 |
# File 'lib/jma_code/point_amedas.rb', line 4 def name @name end |
#name_phonetic ⇒ Object
Returns the value of attribute name_phonetic
4 5 6 |
# File 'lib/jma_code/point_amedas.rb', line 4 def name_phonetic @name_phonetic end |
#observation_started_since ⇒ Object
Returns the value of attribute observation_started_since
4 5 6 |
# File 'lib/jma_code/point_amedas.rb', line 4 def observation_started_since @observation_started_since end |
#type ⇒ Object
Returns the value of attribute type
4 5 6 |
# File 'lib/jma_code/point_amedas.rb', line 4 def type @type end |
Class Method Details
.build_by_csv_row(row, managed_by: nil) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/jma_code/point_amedas.rb', line 56 def build_by_csv_row(row, managed_by: nil) new( code: row[:code], name: row[:name], name_phonetic: row[:name_phonetic], managed_by: managed_by, 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], altitude_anemometer: row[:altitude_anemometer], altitude_thermometer: row[:altitude_thermometer], observation_started_since: row[:observation_started_since], ) end |
.load(csv, num_headers: 2) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/jma_code/point_amedas.rb', line 41 def load(csv, num_headers: 2) managed_by = nil list = [] csv.each.with_index do |row, i| next if i < num_headers branch = row[:government_branch_name] if branch && branch.end_with?('管理') managed_by = branch else list << build_by_csv_row(row, managed_by: managed_by) end end list end |
.load_20240325(&block) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/jma_code/point_amedas.rb', line 29 def load_20240325(&block) path = File.join(File.dirname(__FILE__), "../../data/20240325_PointAmedas/ame_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 |