Sha256: 83c6337ca4d8d81e283f40871ab3fc3f7259d1c29ef11851234b30ede850fa98

Contents?: true

Size: 1.92 KB

Versions: 2

Compression:

Stored size: 1.92 KB

Contents

# frozen_string_literal: true

module Edtf
  module Humanize
    require 'edtf'

    require 'edtf/humanize/language'
    require 'edtf/humanize/decade'
    require 'edtf/humanize/century'
    require 'edtf/humanize/season'
    require 'edtf/humanize/interval'
    require 'edtf/humanize/set'
    require 'edtf/humanize/unknown'
    require 'edtf/humanize/iso_date'
    require 'edtf/humanize/language/default/formats'
    require 'edtf/humanize/language/default/decade'
    require 'edtf/humanize/language/default/century'
    require 'edtf/humanize/language/default/season'
    require 'edtf/humanize/language/default/interval'
    require 'edtf/humanize/language/default/set'
    require 'edtf/humanize/language/default/unknown'
    require 'edtf/humanize/language/default/iso_date'
    require 'edtf/humanize/language/default'
    require 'edtf/humanize/language/english'
    require 'edtf/humanize/language/french'
    require 'edtf/humanize/language/italian'

    EDTF::Decade.include Edtf::Humanize::Decade
    EDTF::Century.include Edtf::Humanize::Century
    EDTF::Season.include Edtf::Humanize::Season
    EDTF::Interval.include Edtf::Humanize::Interval
    EDTF::Set.include Edtf::Humanize::Set
    EDTF::Unknown.include Edtf::Humanize::Unknown
    Date.include Edtf::Humanize::IsoDate

    def self.configuration
      @configuration ||= Configuration.new
    end

    def self.configuration=(configuration)
      @configuration = configuration
    end

    def self.configure
      yield configuration
    end

    class Configuration
      def initialize
        @language_strategies = {
          default: Edtf::Humanize::Language::Default,
          en: Edtf::Humanize::Language::English,
          fr: Edtf::Humanize::Language::French,
          it: Edtf::Humanize::Language::Italian
        }
      end

      def language_strategy(language)
        @language_strategies[language.to_sym] || @language_strategies[:default]
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
edtf-humanize-2.1.0 lib/edtf/humanize.rb
edtf-humanize-2.0.1 lib/edtf/humanize.rb