Class: JMACode::AreaForecastLocal
- Inherits:
-
Struct
- Object
- Struct
- JMACode::AreaForecastLocal
- Defined in:
- lib/jma_code/area_forecast_local.rb
Constant Summary collapse
- HEADERS =
%i( code name name_phonetic )
Class Attribute Summary collapse
-
.area_information_cities ⇒ Object
Returns the value of attribute area_information_cities.
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.
-
#used_by ⇒ Object
Returns the value of attribute used_by.
Class Method Summary collapse
Instance Method Summary collapse
Class Attribute Details
.area_information_cities ⇒ Object
Returns the value of attribute area_information_cities.
16 17 18 |
# File 'lib/jma_code/area_forecast_local.rb', line 16 def area_information_cities @area_information_cities end |
Instance Attribute Details
#code ⇒ Object
Returns the value of attribute code
5 6 7 |
# File 'lib/jma_code/area_forecast_local.rb', line 5 def code @code end |
#name ⇒ Object
Returns the value of attribute name
5 6 7 |
# File 'lib/jma_code/area_forecast_local.rb', line 5 def name @name end |
#name_phonetic ⇒ Object
Returns the value of attribute name_phonetic
5 6 7 |
# File 'lib/jma_code/area_forecast_local.rb', line 5 def name_phonetic @name_phonetic end |
#used_by ⇒ Object
Returns the value of attribute used_by
5 6 7 |
# File 'lib/jma_code/area_forecast_local.rb', line 5 def used_by @used_by end |
Class Method Details
.build_by_csv_row(row) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/jma_code/area_forecast_local.rb', line 39 def build_by_csv_row(row) new( code: row[:code], name: row[:name], name_phonetic: row[:name_phonetic], ) end |
.load(csv, num_headers: 3) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/jma_code/area_forecast_local.rb', line 30 def load(csv, num_headers: 3) list = [] csv.each.with_index do |row, i| next if i < num_headers list << build_by_csv_row(row) end list end |
.load_20240216(&block) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/jma_code/area_forecast_local.rb', line 18 def load_20240216(&block) path = File.join(File.dirname(__FILE__), "../../data/20240216_AreaInformationCity-AreaForecastLocalM/AreaForecastLocalM(コード表).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: 3, &block) end end end |
Instance Method Details
#area_information_city ⇒ Object
48 49 50 |
# File 'lib/jma_code/area_forecast_local.rb', line 48 def area_information_city @area_information_city ||= (self.class.area_information_cities || []).find{|x| x.area_forecast_local_code == code} end |