Sha256: 1b349e3661f028727f765eab69b00c09dabe94f292049bf6c31557ddb4f398cf

Contents?: true

Size: 415 Bytes

Versions: 2

Compression:

Stored size: 415 Bytes

Contents

require 'eorzea_weather/locale'
require 'eorzea_weather/data/locales'

module EorzeaWeather
  class Localizer
    def initialize(kind, id)
      @kind = kind
      @id = id
    end

    attr_reader :kind, :id

    def [](locale)
      to_h[locale] || id.to_s
    end

    def to_h
      @hash ||= Data::Locales::MAP.map { |lid, locale| [lid, locale.__send__(kind)[id]] }.select { |(_,v)| v }.to_h
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
eorzea_weather-0.1.1 lib/eorzea_weather/localizer.rb
eorzea_weather-0.1.0 lib/eorzea_weather/localizer.rb