Class: JMACode::AreaMarine::A
- Inherits:
-
Struct
- Object
- Struct
- JMACode::AreaMarine::A
- Defined in:
- lib/jma_code/area_marine.rb
Constant Summary collapse
- HEADERS =
%i( code name name_phonetic )
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 Attribute Details
#code ⇒ Object
Returns the value of attribute code
4 5 6 |
# File 'lib/jma_code/area_marine.rb', line 4 def code @code end |
#name ⇒ Object
Returns the value of attribute name
4 5 6 |
# File 'lib/jma_code/area_marine.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_marine.rb', line 4 def name_phonetic @name_phonetic end |
Class Method Details
.build_by_csv_row(row) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/jma_code/area_marine.rb', line 36 def build_by_csv_row(row) new( code: row[:code], name: row[:name], name_phonetic: row[:name_phonetic], ) end |
.load(csv, num_headers: 2) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/jma_code/area_marine.rb', line 27 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
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/jma_code/area_marine.rb', line 15 def load_20130523(&block) path = File.join(File.dirname(__FILE__), "../../data/20130523_AreaMarineAJ/AreaMarineA.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 |