Class: Vinber::Translate
- Inherits:
-
Object
- Object
- Vinber::Translate
- Defined in:
- lib/vinber/translate.rb
Constant Summary collapse
- VALUE_LABLE =
"vinber.%{klass}.%{attribute}_%{key}"
Instance Method Summary collapse
-
#initialize(klass, attribute, attribute_vinber_key) ⇒ Translate
constructor
A new instance of Translate.
- #label ⇒ Object
- #text ⇒ Object (also: #to_s)
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
#label ⇒ Object
14 15 16 |
# File 'lib/vinber/translate.rb', line 14 def label @label ||= %() end |
#text ⇒ Object 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 |