Sha256: a954aa365a555179aadbe18f46b815a910236f51d413818d53c3c24c754f1876
Contents?: true
Size: 814 Bytes
Versions: 1
Compression:
Stored size: 814 Bytes
Contents
require 'active_support/core_ext' require 'yaml' module Csv2hash class YamlLoader attr_reader :conf attr_accessor :definition def initialize file @conf = YAML.load_file(file) self.conf.deep_symbolize_keys! end def load! mapping = self.conf.fetch(:mapping) header_size = self.conf.fetch(:header_size).to_i structure_rules = self.conf.fetch(:structure_rules) self.definition = Main.generate_definition self.conf.fetch(:name) do set_type { mapping } set_header_size { header_size } set_structure_rules { structure_rules } end self.conf.fetch(:rules).each do |rule| definition.cells << Cell.new(rule) end Main[self.conf.fetch(:name)] = self.definition end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
csv2hash-0.6.3 | lib/csv2hash/yaml_loader.rb |