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
+ (Object) parser
23
24
25
|
# File 'lib/i18n/locale/tag/rfc4646.rb', line 23
def parser
@@parser ||= Rfc4646::Parser
end
|
+ (Object) parser=(parser)
27
28
29
|
# File 'lib/i18n/locale/tag/rfc4646.rb', line 27
def parser=(parser)
@@parser = parser
end
|
+ (Object) tag(tag)
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
- (Object) to_a
46
47
48
|
# File 'lib/i18n/locale/tag/rfc4646.rb', line 46
def to_a
members.collect { |attr| self.send(attr) }
end
|
- (Object) to_s
42
43
44
|
# File 'lib/i18n/locale/tag/rfc4646.rb', line 42
def to_s
@tag ||= to_a.compact.join("-")
end
|
- (Object) to_sym
38
39
40
|
# File 'lib/i18n/locale/tag/rfc4646.rb', line 38
def to_sym
to_s.to_sym
end
|