Class: I18n::Locale::Tag::Rfc4646

Inherits:
Struct show all
Includes:
Parents
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/i18n-1.12.0/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

Methods inherited from Struct

#as_json

Class Method Details

.parserObject



23
24
25
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/i18n-1.12.0/lib/i18n/locale/tag/rfc4646.rb', line 23

def parser
  @@parser ||= Rfc4646::Parser
end

.parser=(parser) ⇒ Object



27
28
29
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/i18n-1.12.0/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/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/i18n-1.12.0/lib/i18n/locale/tag/rfc4646.rb', line 18

def tag(tag)
  matches = parser.match(tag)
  new(*matches) if matches
end

Instance Method Details

#to_aObject



46
47
48
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/i18n-1.12.0/lib/i18n/locale/tag/rfc4646.rb', line 46

def to_a
  members.collect { |attr| self.send(attr) }
end

#to_sObject



42
43
44
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/i18n-1.12.0/lib/i18n/locale/tag/rfc4646.rb', line 42

def to_s
  @tag ||= to_a.compact.join("-")
end

#to_symObject



38
39
40
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/i18n-1.12.0/lib/i18n/locale/tag/rfc4646.rb', line 38

def to_sym
  to_s.to_sym
end