Sha256: 84d1c84c003b680bdd9a83c127cc70b6d3720b0fff3c80539dbc067975b64eb2

Contents?: true

Size: 670 Bytes

Versions: 1

Compression:

Stored size: 670 Bytes

Contents

require "yaml"
require "pathname"

require "pry"

module Atethechon
  class ContactParser
    attr_reader :data_directory

    def initialize(options = {})
      @data_directory = options.fetch(:data_directory) { Pathname.new(File.expand_path("../..", File.dirname(__dir__))).join("data") }
    end

    def load
      Dir[data_directory.join("**/*.yml")].sort.each_with_object([]) do |data_file, result|
        data = YAML.load_file(data_file)
        data.each do |_organization_identifier, attributes|
          attributes.fetch("contacts").each do |contact_data|
            result << Contact.new(contact_data)
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
atethechon-0.1.0 lib/atethechon/parsers/contact_parser.rb