Class: Fotolia::Language
- Inherits:
-
Object
- Object
- Fotolia::Language
- Defined in:
- lib/fotolia/language.rb
Overview
Constant Summary collapse
- LANGUAGE_IDS =
Translate language code-like symbols to their ids at Fotolia.
{ :fr => 1, :en_us => 2, :en_uk => 3, :de => 4, :es => 5, :it => 6, :pt_pt => 7, :pt_br => 8, :jp => 9, :pl => 11 }
Instance Method Summary collapse
- #id ⇒ Object
-
#initialize(id_or_lang_sym) ⇒ Language
constructor
A new instance of Language.
- #to_s ⇒ Object (also: #to_code)
- #to_sym ⇒ Object
Constructor Details
#initialize(id_or_lang_sym) ⇒ Language
Returns a new instance of Language.
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/fotolia/language.rb', line 32 def initialize(id_or_lang_sym) if(id_or_lang_sym.is_a?(Symbol)) raise Fotolia::LanguageNotDefinedError and return nil unless(LANGUAGE_IDS.has_key?(id_or_lang_sym)) @language_sym = id_or_lang_sym else raise Fotolia::LanguageNotDefinedError and return nil unless(LANGUAGE_IDS.has_value?(id_or_lang_sym)) @language_sym = LANGUAGE_IDS.invert[id_or_lang_sym] end self end |
Instance Method Details
#id ⇒ Object
54 55 56 |
# File 'lib/fotolia/language.rb', line 54 def id LANGUAGE_IDS[@language_sym] end |
#to_s ⇒ Object Also known as: to_code
44 45 46 |
# File 'lib/fotolia/language.rb', line 44 def to_s @language_sym.to_s end |
#to_sym ⇒ Object
50 51 52 |
# File 'lib/fotolia/language.rb', line 50 def to_sym @language_sym end |