Sha256: fde495a47c6ce0124d46f16dba21e7c271d208680b8fe1b026a558c1d76421c1

Contents?: true

Size: 453 Bytes

Versions: 2

Compression:

Stored size: 453 Bytes

Contents

# frozen_string_literal: true

require "yaml"

module Gooday
  # Use YAML instead of Ruby to set a translation
  class YAMLParser
    AUTHORIZED_KEYS = %w[short long months days short_months short_days formats].freeze

    def initialize(file)
      @file = YAML.load_file(file)
    end

    def translations
      @file.each_with_object({}) do |(key, value), hash|
        hash[key] = value if AUTHORIZED_KEYS.include?(key)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gooday-0.1.2 lib/gooday/yaml_parser.rb
gooday-0.1.1 lib/gooday/yaml_parser.rb