Class: Gaigo::Langs
- Inherits:
-
Array
- Object
- Array
- Gaigo::Langs
- Defined in:
- lib/gaigo/langs.rb
Defined Under Namespace
Classes: Lang
Instance Method Summary collapse
- #add_lang(attributes) ⇒ Object
- #codes ⇒ Object
- #copy(*locale_codes) ⇒ Object
- #en ⇒ Object
- #get(code) ⇒ Object
- #native ⇒ Object
Instance Method Details
#add_lang(attributes) ⇒ Object
23 24 25 |
# File 'lib/gaigo/langs.rb', line 23 def add_lang(attributes) self << Lang.new(*attributes) end |
#codes ⇒ Object
31 32 33 |
# File 'lib/gaigo/langs.rb', line 31 def codes self.map {|i| i.code} end |
#copy(*locale_codes) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/gaigo/langs.rb', line 43 def copy(*locale_codes) if locale_codes.any? Langs.new.tap do |new_langs| locale_codes.each do |code| new_langs << get(code.to_s) end end else self.dup end end |
#en ⇒ Object
35 36 37 |
# File 'lib/gaigo/langs.rb', line 35 def en self.map {|i| i.en} end |
#get(code) ⇒ Object
27 28 29 |
# File 'lib/gaigo/langs.rb', line 27 def get(code) self.find {|i| i.code == code.to_s} end |
#native ⇒ Object
39 40 41 |
# File 'lib/gaigo/langs.rb', line 39 def native self.map {|i| i.native} end |