Class: Transfluent::Language
- Inherits:
-
Object
- Object
- Transfluent::Language
- Defined in:
- lib/transfluent/language.rb
Overview
Represents a language that can be identified by an IETF language tag or Transfluent specific id
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
-
.get(code) ⇒ Language
Get an instance of language by code.
- .get_by_id(id) ⇒ Object
Instance Method Summary collapse
-
#initialize(id, code, name) ⇒ Language
constructor
A new instance of Language.
Constructor Details
#initialize(id, code, name) ⇒ Language
27 28 29 30 31 |
# File 'lib/transfluent/language.rb', line 27 def initialize id, code, name @id = id.to_i @code = code @name = name end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
8 9 10 |
# File 'lib/transfluent/language.rb', line 8 def code @code end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
8 9 10 |
# File 'lib/transfluent/language.rb', line 8 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/transfluent/language.rb', line 8 def name @name end |
Class Method Details
.get(code) ⇒ Language
Get an instance of language by code
15 16 17 18 19 |
# File 'lib/transfluent/language.rb', line 15 def self.get code Language.fetch if $languages_by_code.nil? $languages_by_code[code] end |
.get_by_id(id) ⇒ Object
21 22 23 24 25 |
# File 'lib/transfluent/language.rb', line 21 def self.get_by_id id Language.fetch if $languages_by_code.nil? $languages_by_id[id] end |