Class: BCP47::Language
Constant Summary collapse
- DEFINITIONS_FILE =
"#{File.dirname(__FILE__)}/../../data/iso-639-1.yml"
- DEFAULT_PLURAL_RULE_NAMES =
%w(one other)
- DEFAULT_DIRECTION =
'ltr'
- DEFAULT_CODE =
'en'
- PLURAL_RULE_NAMES =
%w(zero one two few many other)
Instance Attribute Summary collapse
-
#direction ⇒ Object
readonly
Returns the value of attribute direction.
-
#plural_rule_names ⇒ Object
readonly
Returns the value of attribute plural_rule_names.
Attributes inherited from Subtag
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(code, options = {}) ⇒ Language
constructor
A new instance of Language.
Methods inherited from Subtag
#==, all, codes, default, find, #full_name, #name
Constructor Details
#initialize(code, options = {}) ⇒ Language
Returns a new instance of Language.
10 11 12 13 14 |
# File 'lib/bcp47/language.rb', line 10 def initialize(code, ={}) @plural_rule_names = [:plural_rule_names] || DEFAULT_PLURAL_RULE_NAMES @direction = [:direction] || DEFAULT_DIRECTION super(code, ) end |
Instance Attribute Details
#direction ⇒ Object (readonly)
Returns the value of attribute direction.
8 9 10 |
# File 'lib/bcp47/language.rb', line 8 def direction @direction end |
#plural_rule_names ⇒ Object (readonly)
Returns the value of attribute plural_rule_names.
8 9 10 |
# File 'lib/bcp47/language.rb', line 8 def plural_rule_names @plural_rule_names end |
Class Method Details
.identify(full_code) ⇒ Object
16 17 18 19 |
# File 'lib/bcp47/language.rb', line 16 def self.identify(full_code) segments = full_code.split('-') segments.first =~ /^([a-z]{2})$/ ? find($1) : nil end |