class Dech::Dena::CSV
Constants
- ENCODING
- HEADER_MAPPINGS
- REQUIRED_HEADERS
- STATIC_COLUMNS
Public Class Methods
new(products)
click to toggle source
Calls superclass method
Dech::CSV::new
# File lib/dech/dena/csv.rb, line 23 def initialize(products) @products = products super(formatted_products) end
Public Instance Methods
valid?()
click to toggle source
# File lib/dech/dena/csv.rb, line 28 def valid? validate! rescue false end
validate!()
click to toggle source
# File lib/dech/dena/csv.rb, line 32 def validate! translated_products.each do |product| REQUIRED_HEADERS.each do |header| raise "#{header} is missing in #{product}" unless product.keys.include?(header) end end end
Private Instance Methods
formatted_products()
click to toggle source
# File lib/dech/dena/csv.rb, line 42 def formatted_products emmental = Emmental.new translated_products.each{|product| emmental << product } emmental.to_a end
merged_products()
click to toggle source
# File lib/dech/dena/csv.rb, line 52 def merged_products @products.map{|product| STATIC_COLUMNS.merge(product) } end
translated_products()
click to toggle source
# File lib/dech/dena/csv.rb, line 48 def translated_products merged_products.map{|product| Dech::HashKeyMapper.map(product, HEADER_MAPPINGS) } end