Class: Webgen::Language
- Inherits:
-
Object
- Object
- Webgen::Language
- Includes:
- Comparable
- Defined in:
- lib/webgen/languages.rb
Overview
Describes a human language which is uniquely identfied by a three letter code and, optionally, by an alternative three letter or a two letter code.
Instance Attribute Summary collapse
-
#codes ⇒ Object
readonly
An array containing the language codes for the language.
-
#description ⇒ Object
readonly
The english description of the language.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
:nodoc:.
-
#code2chars ⇒ Object
The two letter code.
-
#code3chars ⇒ Object
The three letter code.
-
#code3chars_alternative ⇒ Object
The alternative three letter code.
-
#initialize(codes, description) ⇒ Language
constructor
Create a new language.
-
#inspect ⇒ Object
:nodoc:.
-
#to_s ⇒ Object
(also: #to_str)
The textual representation of the language.
Constructor Details
#initialize(codes, description) ⇒ Language
Create a new language. codes has to be an array containing three strings: the three letter code, the alternative three letter code and the two letter code. If one is not available for the language, it has to be nil.
18 19 20 21 |
# File 'lib/webgen/languages.rb', line 18 def initialize(codes, description) @codes = codes @description = description end |
Instance Attribute Details
#codes ⇒ Object (readonly)
An array containing the language codes for the language.
10 11 12 |
# File 'lib/webgen/languages.rb', line 10 def codes @codes end |
#description ⇒ Object (readonly)
The english description of the language.
13 14 15 |
# File 'lib/webgen/languages.rb', line 13 def description @description end |
Instance Method Details
#<=>(other) ⇒ Object
:nodoc:
49 50 51 |
# File 'lib/webgen/languages.rb', line 49 def <=>(other) #:nodoc: self.to_s <=> other.to_s end |
#code2chars ⇒ Object
The two letter code.
24 25 26 |
# File 'lib/webgen/languages.rb', line 24 def code2chars @codes[2] end |
#code3chars ⇒ Object
The three letter code.
29 30 31 |
# File 'lib/webgen/languages.rb', line 29 def code3chars @codes[0] end |
#code3chars_alternative ⇒ Object
The alternative three letter code.
34 35 36 |
# File 'lib/webgen/languages.rb', line 34 def code3chars_alternative @codes[1] end |
#inspect ⇒ Object
:nodoc:
45 46 47 |
# File 'lib/webgen/languages.rb', line 45 def inspect #:nodoc: "#<Language codes=#{codes.inspect} description=#{description.inspect}>" end |
#to_s ⇒ Object Also known as: to_str
The textual representation of the language.
39 40 41 |
# File 'lib/webgen/languages.rb', line 39 def to_s code2chars || code3chars end |