Class: It::Interpolation

Inherits:
Object
  • Object
show all
Defined in:
lib/it/interpolation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(string, values) ⇒ Interpolation

Returns a new instance of Interpolation.



5
6
7
8
9
10
# File 'lib/it/interpolation.rb', line 5

def initialize(string, values)
  self.key, self.label = string[2..-2].split(':', 2)
  self.values = values

  convert_links
end

Instance Attribute Details

#keyObject

Returns the value of attribute key.



3
4
5
# File 'lib/it/interpolation.rb', line 3

def key
  @key
end

#labelObject

Returns the value of attribute label.



3
4
5
# File 'lib/it/interpolation.rb', line 3

def label
  @label
end

#valuesObject

Returns the value of attribute values.



3
4
5
# File 'lib/it/interpolation.rb', line 3

def values
  @values
end

Instance Method Details

#processObject



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/it/interpolation.rb', line 12

def process
  check_input_values

  if label # Normal tags
    values[key].process(label.html_safe)
  elsif values[key].is_a?(It::Tag) # Empty tag
    values[key].process
  else # Normal interpolations, as I18n.t would do it.
    ERB::Util.h(values[key])
  end
end