Class: I18n::Locale::Tag::Rfc4646
- Inherits:
-
Struct
- Object
- Struct
- I18n::Locale::Tag::Rfc4646
show all
- Includes:
- Parents
- Defined in:
- lib/i18n/locale/tag/rfc4646.rb
Defined Under Namespace
Modules: Parser
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Parents
#parent, #parents, #self_and_parents
Class Method Details
.parser ⇒ Object
23
24
25
|
# File 'lib/i18n/locale/tag/rfc4646.rb', line 23
def parser
@@parser ||= Rfc4646::Parser
end
|
.parser=(parser) ⇒ Object
27
28
29
|
# File 'lib/i18n/locale/tag/rfc4646.rb', line 27
def parser=(parser)
@@parser = parser
end
|
.tag(tag) ⇒ Object
Parses the given tag and returns a Tag instance if it is valid. Returns false if the given tag is not valid according to RFC 4646.
18
19
20
21
|
# File 'lib/i18n/locale/tag/rfc4646.rb', line 18
def tag(tag)
matches = parser.match(tag)
new(*matches) if matches
end
|
Instance Method Details
#to_a ⇒ Object
46
47
48
|
# File 'lib/i18n/locale/tag/rfc4646.rb', line 46
def to_a
members.collect { |attr| self.send(attr) }
end
|
#to_s ⇒ Object
42
43
44
|
# File 'lib/i18n/locale/tag/rfc4646.rb', line 42
def to_s
@tag ||= to_a.compact.join("-")
end
|
#to_sym ⇒ Object
38
39
40
|
# File 'lib/i18n/locale/tag/rfc4646.rb', line 38
def to_sym
to_s.to_sym
end
|