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.
-
#value ⇒ String
Value of tag.
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.
Methods inherited from OOXMLDocumentObject
#==, add_to_xmls_stack, copy_file_and_rename_to_zip, current_xml, dir, encrypted_file?, get_link_from_rels, unzip_file, #with_data?
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) @parent = parent @type = type 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 |
#value ⇒ String
Returns value of tag.
5 6 7 |
# File 'lib/ooxml_parser/common_parser/common_data/valued_child.rb', line 5 def value @value end |
Instance Method Details
#parse(node) ⇒ ValuedChild
Parse ValuedChild object
17 18 19 20 21 22 23 24 25 26 27 |
# 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 end end self end |