Class: JMACode::AreaFloodForecast
- Inherits:
-
Struct
- Object
- Struct
- JMACode::AreaFloodForecast
- Defined in:
- lib/jma_code/area_flood_forecast.rb
Constant Summary collapse
- CSV_ROW_SEP =
"\r\n"
- HEADERS =
%i(code name name_phonetic)
- NUM_HEADER_ROWS =
3
Class Attribute Summary collapse
-
.data ⇒ Object
Returns the value of attribute data.
Instance Attribute Summary collapse
-
#code ⇒ Object
Returns the value of attribute code.
-
#name ⇒ Object
Returns the value of attribute name.
-
#name_phonetic ⇒ Object
Returns the value of attribute name_phonetic.
Class Method Summary collapse
Instance Method Summary collapse
Class Attribute Details
.data ⇒ Object
Returns the value of attribute data.
13 14 15 |
# File 'lib/jma_code/area_flood_forecast.rb', line 13 def data @data end |
Instance Attribute Details
#code ⇒ Object
Returns the value of attribute code
4 5 6 |
# File 'lib/jma_code/area_flood_forecast.rb', line 4 def code @code end |
#name ⇒ Object
Returns the value of attribute name
4 5 6 |
# File 'lib/jma_code/area_flood_forecast.rb', line 4 def name @name end |
#name_phonetic ⇒ Object
Returns the value of attribute name_phonetic
4 5 6 |
# File 'lib/jma_code/area_flood_forecast.rb', line 4 def name_phonetic @name_phonetic end |
Class Method Details
.get ⇒ Object
35 36 37 |
# File 'lib/jma_code/area_flood_forecast.rb', line 35 def get @data ||= load end |
.load(**args) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/jma_code/area_flood_forecast.rb', line 23 def load(**args) load_csv(**args) do |csv| csv.drop(NUM_HEADER_ROWS).map do |row| new( code: row[:code], name: row[:name], name_phonetic: row[:name_phonetic] ) end end end |
.load_csv(version: "20230105") ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/jma_code/area_flood_forecast.rb', line 15 def load_csv(version: "20230105") path = File.join(File.dirname(__FILE__), "../../data/#{version}_AreaFloodForecast.csv") File.open(path) do |f| csv = CSV.new(f, headers: HEADERS, row_sep: CSV_ROW_SEP) yield(csv) end end |
Instance Method Details
#area_river ⇒ Object
44 45 46 |
# File 'lib/jma_code/area_flood_forecast.rb', line 44 def area_river @area_river ||= AreaRiver.get.find{|ar| ar.code == river_code} end |
#river_code ⇒ Object
40 41 42 |
# File 'lib/jma_code/area_flood_forecast.rb', line 40 def river_code code[0..9] end |