Class: Bipm::Data::Importer::Language
- Inherits:
-
Object
- Object
- Bipm::Data::Importer::Language
- Defined in:
- lib/bipm/data/importer/language.rb
Overview
First-class language value object. English and French are equal citizens — neither is the canonical form, neither is a translation of the other. Both directions of any linguistic operation must be expressible through this type without one being the "default".
Constant Summary collapse
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
Class Method Summary collapse
Instance Method Summary collapse
- #directory_suffix ⇒ Object
- #eql?(other) ⇒ Boolean (also: #==)
- #hash ⇒ Object
-
#initialize(code) ⇒ Language
constructor
A new instance of Language.
- #suffix ⇒ Object
- #to_s ⇒ Object
- #to_sym ⇒ Object
Constructor Details
#initialize(code) ⇒ Language
Returns a new instance of Language.
13 14 15 |
# File 'lib/bipm/data/importer/language.rb', line 13 def initialize(code) @code = code end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
11 12 13 |
# File 'lib/bipm/data/importer/language.rb', line 11 def code @code end |
Class Method Details
.all ⇒ Object
27 28 29 |
# File 'lib/bipm/data/importer/language.rb', line 27 def self.all ALL end |
Instance Method Details
#directory_suffix ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/bipm/data/importer/language.rb', line 47 def directory_suffix case @code when :en then "-en" when :fr then "-fr" else raise(ArgumentError, "no directory suffix for #{@code}") end end |
#eql?(other) ⇒ Boolean Also known as: ==
55 56 57 |
# File 'lib/bipm/data/importer/language.rb', line 55 def eql?(other) other.is_a?(Language) && @code == other.code end |
#hash ⇒ Object
60 61 62 |
# File 'lib/bipm/data/importer/language.rb', line 60 def hash @code.hash end |
#suffix ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/bipm/data/importer/language.rb', line 39 def suffix case @code when :en then "" when :fr then "-fr" else raise(ArgumentError, "no suffix defined for #{@code}") end end |
#to_s ⇒ Object
31 32 33 |
# File 'lib/bipm/data/importer/language.rb', line 31 def to_s @code.to_s end |
#to_sym ⇒ Object
35 36 37 |
# File 'lib/bipm/data/importer/language.rb', line 35 def to_sym @code end |