Class: Burek::BurekCall

Inherits:
Object
  • Object
show all
Defined in:
lib/core/burek_call.rb

Instance Method Summary collapse

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, options={})
  if translation.is_a?(Hash)
    @translation = translation
  else
    @translation = {default_locale => translation }
  end
  @key = options[:key] || key_from_translation
  @parent_key = options[:parent_key] || ''
end

Instance Method Details

#full_keyObject



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

#keyObject



24
25
26
# File 'lib/core/burek_call.rb', line 24

def key
  @key
end

#parent_keyObject



28
29
30
# File 'lib/core/burek_call.rb', line 28

def parent_key
  @parent_key
end

#parent_key_arrayObject



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