Sha256: d85a40a7a712487adb8d152d89b14c27ccfb6ac4ea44b85d199098b5f222cf6e

Contents?: true

Size: 708 Bytes

Versions: 2

Compression:

Stored size: 708 Bytes

Contents

require 'i18n/locale/tag/parents'

# Simple Locale tag implementation that computes subtags by simply splitting
# the locale tag at '-' occurences.

module I18n
  module Locale
    module Tag
      class Simple
        class << self
          def tag(tag)
            new(tag)
          end
        end

        include Parents

        attr_reader :tag

        def initialize(*tag)
          @tag = tag.join('-').to_sym
        end

        def subtags
          @subtags = tag.to_s.split('-').map { |subtag| subtag.to_s }
        end

        def to_sym
          tag
        end

        def to_s
          tag.to_s
        end

        def to_a
          subtags
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
theoooo-i18n-0.2.1 lib/i18n/locale/tag/simple.rb
theoooo-i18n-0.2.2 lib/i18n/locale/tag/simple.rb