~ubuntu-branches/ubuntu/oneiric/ruby-activesupport-2.3/oneiric-updates

« back to all changes in this revision

Viewing changes to lib/active_support/vendor/i18n-0.4.1/i18n/locale/tag/simple.rb

  • Committer: Bazaar Package Importer
  • Author(s): Ondřej Surý
  • Date: 2011-06-01 14:30:04 UTC
  • Revision ID: james.westby@ubuntu.com-20110601143004-wy5jrvj06x72qiqs
Tags: upstream-2.3.11
Import upstream version 2.3.11

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# encoding: utf-8
 
2
 
 
3
# Simple Locale tag implementation that computes subtags by simply splitting
 
4
# the locale tag at '-' occurences.
 
5
module I18n
 
6
  module Locale
 
7
    module Tag
 
8
      class Simple
 
9
        class << self
 
10
          def tag(tag)
 
11
            new(tag)
 
12
          end
 
13
        end
 
14
 
 
15
        include Parents
 
16
 
 
17
        attr_reader :tag
 
18
 
 
19
        def initialize(*tag)
 
20
          @tag = tag.join('-').to_sym
 
21
        end
 
22
 
 
23
        def subtags
 
24
          @subtags = tag.to_s.split('-').map { |subtag| subtag.to_s }
 
25
        end
 
26
 
 
27
        def to_sym
 
28
          tag
 
29
        end
 
30
 
 
31
        def to_s
 
32
          tag.to_s
 
33
        end
 
34
 
 
35
        def to_a
 
36
          subtags
 
37
        end
 
38
      end
 
39
    end
 
40
  end
 
41
end