Class: OoxmlParser::ValuedChild
- Inherits:
-
OOXMLDocumentObject
- Object
- OOXMLDocumentObject
- OoxmlParser::ValuedChild
- Defined in:
- lib/ooxml_parser/common_parser/common_data/valued_child.rb
Overview
Class for working with any tag contained only value
Instance Attribute Summary collapse
-
#type ⇒ String
readonly
Type of value.
Attributes inherited from OOXMLDocumentObject
Instance Method Summary collapse
-
#initialize(type = :string, parent: nil) ⇒ ValuedChild
constructor
A new instance of ValuedChild.
-
#parse(node) ⇒ ValuedChild
Parse ValuedChild object.
-
#value ⇒ Object
Value of parameter.
Methods inherited from OOXMLDocumentObject
#==, #boolean_attribute_value, #parse_xml, #with_data?
Methods included from OoxmlObjectAttributeHelper
#attribute_enabled?, #option_enabled?
Methods included from OoxmlDocumentObjectHelper
Constructor Details
#initialize(type = :string, parent: nil) ⇒ ValuedChild
Returns a new instance of ValuedChild.
9 10 11 12 |
# File 'lib/ooxml_parser/common_parser/common_data/valued_child.rb', line 9 def initialize(type = :string, parent: nil) @type = type super(parent: parent) end |
Instance Attribute Details
#type ⇒ String (readonly)
Returns type of value.
7 8 9 |
# File 'lib/ooxml_parser/common_parser/common_data/valued_child.rb', line 7 def type @type end |
Instance Method Details
#parse(node) ⇒ ValuedChild
Parse ValuedChild object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/ooxml_parser/common_parser/common_data/valued_child.rb', line 17 def parse(node) node.attributes.each do |key, value| case key when 'val' @value = value.value.to_s if type == :string @value = value_to_symbol(value) if type == :symbol @value = value.value.to_i if type == :integer @value = value.value.to_f if type == :float @value = parse_boolean(value.value.to_s) if type == :boolean end end self end |
#value ⇒ Object
Returns value of parameter.
32 33 34 35 36 |
# File 'lib/ooxml_parser/common_parser/common_data/valued_child.rb', line 32 def value return true if type == :boolean && @value.nil? @value end |