Class: Burek::BurekCall
- Inherits:
-
Object
- Object
- Burek::BurekCall
- Defined in:
- lib/core/burek_call.rb
Instance Method Summary collapse
- #full_key ⇒ Object
-
#initialize(translation, options = {}) ⇒ BurekCall
constructor
A new instance of BurekCall.
- #key ⇒ Object
- #parent_key ⇒ Object
- #parent_key_array ⇒ Object
- #translation(locale = nil) ⇒ Object
Constructor Details
#initialize(translation, options = {}) ⇒ BurekCall
Returns a new instance of BurekCall.
4 5 6 7 8 9 10 11 12 |
# File 'lib/core/burek_call.rb', line 4 def initialize(translation, ={}) if translation.is_a?(Hash) @translation = translation else @translation = {default_locale => translation } end @key = [:key] || key_from_translation @parent_key = [:parent_key] || '' end |
Instance Method Details
#full_key ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/core/burek_call.rb', line 32 def full_key if parent_key.nil? || parent_key.length == 0 key else parent_key + "." + key end end |
#key ⇒ Object
24 25 26 |
# File 'lib/core/burek_call.rb', line 24 def key @key end |
#parent_key ⇒ Object
28 29 30 |
# File 'lib/core/burek_call.rb', line 28 def parent_key @parent_key end |
#parent_key_array ⇒ Object
40 41 42 |
# File 'lib/core/burek_call.rb', line 40 def parent_key_array @parent_key.split('.') end |
#translation(locale = nil) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/core/burek_call.rb', line 14 def translation(locale=nil) locale ||= default_locale locale = locale.to_s if @translation.has_key?(locale) return @translation[locale] else return Burek.config.get(:translation_placeholder) end end |