Class: Vinber::Translate

Inherits:
Object
  • Object
show all
Defined in:
lib/vinber/translate.rb

Constant Summary collapse

VALUE_LABLE =
"vinber.%{klass}.%{attribute}_%{key}"

Instance Method Summary collapse

Constructor Details

#initialize(klass, attribute, attribute_vinber_key) ⇒ Translate

Returns a new instance of Translate.



6
7
8
9
10
11
12
# File 'lib/vinber/translate.rb', line 6

def initialize(klass, attribute, attribute_vinber_key)
  @label = {
    :klass     => (klass.is_a?(Class) ? klass.name : klass),
    :attribute => attribute,
    :key       => attribute_vinber_key
  }
end

Instance Method Details

#labelObject



14
15
16
# File 'lib/vinber/translate.rb', line 14

def label
  @label ||= %()
end

#textObject Also known as: to_s



18
19
20
# File 'lib/vinber/translate.rb', line 18

def text
  @text ||= I18n.t (VALUE_LABLE % label), default: label[:key].to_s.humanize
end