Class: Decontaminate::Decoder::Scalar
- Inherits:
-
Object
- Object
- Decontaminate::Decoder::Scalar
- Defined in:
- lib/decontaminate/decoder/scalar.rb
Instance Attribute Summary collapse
-
#transformer ⇒ Object
readonly
Returns the value of attribute transformer.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#xpath ⇒ Object
readonly
Returns the value of attribute xpath.
Instance Method Summary collapse
- #decode(this, xml_node) ⇒ Object
-
#initialize(xpath, type, transformer) ⇒ Scalar
constructor
A new instance of Scalar.
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
#transformer ⇒ Object (readonly)
Returns the value of attribute transformer.
4 5 6 |
# File 'lib/decontaminate/decoder/scalar.rb', line 4 def transformer @transformer end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
4 5 6 |
# File 'lib/decontaminate/decoder/scalar.rb', line 4 def type @type end |
#xpath ⇒ Object (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 |