Class: JMACode::AreaMarine::J
- Inherits:
-
Struct
- Object
- Struct
- JMACode::AreaMarine::J
- Defined in:
- lib/jma_code/area_marine.rb
Constant Summary collapse
- HEADERS =
%i( code name name_phonetic used_by_local_marine_warning used_by_volcanic_marine_warning )
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_local_marine_warning ⇒ Object
Returns the value of attribute used_by_local_marine_warning.
-
#used_by_volcanic_marine_warning ⇒ Object
Returns the value of attribute used_by_volcanic_marine_warning.
Class Method Summary collapse
Instance Attribute Details
#code ⇒ Object
Returns the value of attribute code
46 47 48 |
# File 'lib/jma_code/area_marine.rb', line 46 def code @code end |
#name ⇒ Object
Returns the value of attribute name
46 47 48 |
# File 'lib/jma_code/area_marine.rb', line 46 def name @name end |
#name_phonetic ⇒ Object
Returns the value of attribute name_phonetic
46 47 48 |
# File 'lib/jma_code/area_marine.rb', line 46 def name_phonetic @name_phonetic end |
#used_by_local_marine_warning ⇒ Object
Returns the value of attribute used_by_local_marine_warning
46 47 48 |
# File 'lib/jma_code/area_marine.rb', line 46 def used_by_local_marine_warning @used_by_local_marine_warning end |
#used_by_volcanic_marine_warning ⇒ Object
Returns the value of attribute used_by_volcanic_marine_warning
46 47 48 |
# File 'lib/jma_code/area_marine.rb', line 46 def used_by_volcanic_marine_warning @used_by_volcanic_marine_warning end |
Class Method Details
.build_by_csv_row(row) ⇒ Object
80 81 82 83 84 85 86 87 88 |
# File 'lib/jma_code/area_marine.rb', line 80 def build_by_csv_row(row) new( code: row[:code], name: row[:name], name_phonetic: row[:name_phonetic], used_by_local_marine_warning: row[:used_by_local_marine_warning], used_by_volcanic_marine_warning: row[:used_by_volcanic_marine_warning], ) end |
.load(csv, num_headers: 2) ⇒ Object
71 72 73 74 75 76 77 78 |
# File 'lib/jma_code/area_marine.rb', line 71 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_20130523(&block) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/jma_code/area_marine.rb', line 59 def load_20130523(&block) path = File.join(File.dirname(__FILE__), "../../data/20130523_AreaMarineAJ/AreaMarineJ.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: 4, &block) end end end |