Class: Decontaminate::Decoder::Scalar

Inherits:
Object
  • Object
show all
Defined in:
lib/decontaminate/decoder/scalar.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xpath, type, transformer) ⇒ Scalar

Returns a new instance of Scalar.



6
7
8
9
10
# File 'lib/decontaminate/decoder/scalar.rb', line 6

def initialize(xpath, type, transformer)
  @xpath = xpath
  @type = type
  @transformer = transformer
end

Instance Attribute Details

#transformerObject (readonly)

Returns the value of attribute transformer.



4
5
6
# File 'lib/decontaminate/decoder/scalar.rb', line 4

def transformer
  @transformer
end

#typeObject (readonly)

Returns the value of attribute type.



4
5
6
# File 'lib/decontaminate/decoder/scalar.rb', line 4

def type
  @type
end

#xpathObject (readonly)

Returns the value of attribute xpath.



4
5
6
# File 'lib/decontaminate/decoder/scalar.rb', line 4

def xpath
  @xpath
end

Instance Method Details

#decode(this, xml_node) ⇒ Object



12
13
14
15
16
# File 'lib/decontaminate/decoder/scalar.rb', line 12

def decode(this, xml_node)
  value = value_from_xml_node xml_node
  value = this.instance_exec(value, &transformer) if transformer
  value
end