Module: I18n::Locale::Tag::Parents

Included in:
Rfc4646, Simple
Defined in:
lib/i18n/locale/tag/parents.rb

Instance Method Summary collapse

Instance Method Details

#parentObject



5
6
7
8
9
10
# File 'lib/i18n/locale/tag/parents.rb', line 5

def parent
  @parent ||= begin
    segs = to_a.compact
    segs.length > 1 ? self.class.tag(*segs[0..(segs.length-2)].join('-')) : nil
  end
end

#parentsObject



16
17
18
# File 'lib/i18n/locale/tag/parents.rb', line 16

def parents
  @parents ||= ([parent] + (parent ? parent.parents : [])).compact
end

#self_and_parentsObject



12
13
14
# File 'lib/i18n/locale/tag/parents.rb', line 12

def self_and_parents
  @self_and_parents ||= [self] + parents
end