Class: Semlogr::Templates::PropertyToken

Inherits:
Object
  • Object
show all
Defined in:
lib/semlogr/templates/property_token.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_text, property_name) ⇒ PropertyToken

Returns a new instance of PropertyToken.



8
9
10
11
# File 'lib/semlogr/templates/property_token.rb', line 8

def initialize(raw_text, property_name)
  @raw_text = raw_text
  @property_name = property_name
end

Instance Attribute Details

#property_nameObject

Returns the value of attribute property_name.



6
7
8
# File 'lib/semlogr/templates/property_token.rb', line 6

def property_name
  @property_name
end

Instance Method Details

#==(other) ⇒ Object



23
24
25
26
27
28
# File 'lib/semlogr/templates/property_token.rb', line 23

def ==(other)
  return false unless other
  return false unless other.respond_to?(:property_name)

  @property_name == other.property_name
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/semlogr/templates/property_token.rb', line 30

def eql?(other)
  self == other
end

#hashObject



34
35
36
# File 'lib/semlogr/templates/property_token.rb', line 34

def hash
  @property_name.hash
end

#render(output, properties) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/semlogr/templates/property_token.rb', line 13

def render(output, properties)
  if properties.key?(@property_name)
    property_value = properties[@property_name]

    Formatters::PropertyValueFormatter.format(output, property_value)
  else
    output << @raw_text
  end
end