Class: BCP47::Tag

Inherits:
Object
  • Object
show all
Defined in:
lib/bcp47/tag.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code) ⇒ Tag

Returns a new instance of Tag.



5
6
7
8
9
# File 'lib/bcp47/tag.rb', line 5

def initialize(code)
  @code     = code
  @language = Language.identify(code)
  @region   = Region.identify(code)
end

Instance Attribute Details

#languageObject

Returns the value of attribute language.



3
4
5
# File 'lib/bcp47/tag.rb', line 3

def language
  @language
end

#regionObject

Returns the value of attribute region.



3
4
5
# File 'lib/bcp47/tag.rb', line 3

def region
  @region
end

Instance Method Details

#codesObject



11
12
13
# File 'lib/bcp47/tag.rb', line 11

def codes
  subtags.map(&:code)
end

#subtagsObject



15
16
17
# File 'lib/bcp47/tag.rb', line 15

def subtags
  [language, region].compact
end