Class: Kamome::Transformations::GeneralCsv

Inherits:
Object
  • Object
show all
Includes:
Cleaner
Defined in:
lib/kamome/transformations/general_csv.rb

Overview

Transform a GENERAL csv row to a Hash or others

Constant Summary

Constants included from Cleaner

Cleaner::TOWN_KAN_SUB_RULE, Cleaner::TOWN_SUB_RULE

Instance Method Summary collapse

Methods included from Cleaner

clean_town, clean_town_kana

Instance Method Details

#generate_detail_model(row) ⇒ Object



20
21
22
23
# File 'lib/kamome/transformations/general_csv.rb', line 20

def generate_detail_model(row)
  attributes = generate_hash(row)
  ::Kamome::Models::General.new(attributes)
end

#generate_hash(row) ⇒ Hash

Generate hash from a general csv row

Returns:

  • (Hash)


15
16
17
18
# File 'lib/kamome/transformations/general_csv.rb', line 15

def generate_hash(row)
  validate_row!(row)
  transform(row)
end

#generate_model(row) ⇒ Object



25
26
27
28
# File 'lib/kamome/transformations/general_csv.rb', line 25

def generate_model(row)
  attributes = extract(generate_hash(row))
  ::Kamome::Models::Address.new(attributes)
end