class OoxmlParser::ValuedChild
Class for working with any tag contained only value
Attributes
type[R]
@return [String] type of value
Public Class Methods
new(type = :string, parent: nil)
click to toggle source
Calls superclass method
OoxmlParser::OOXMLDocumentObject::new
# 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
Public Instance Methods
parse(node)
click to toggle source
Parse ValuedChild
object @param node [Nokogiri::XML:Element] node to parse @return [ValuedChild] result of parsing
# 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()
click to toggle source
@return [Object] value of parameter
# File lib/ooxml_parser/common_parser/common_data/valued_child.rb, line 32 def value return true if type == :boolean && @value.nil? @value end
Private Instance Methods
parse_boolean(value)
click to toggle source
Handle boolean value @param [String] value to parse @return [Boolean] result
# File lib/ooxml_parser/common_parser/common_data/valued_child.rb, line 43 def parse_boolean(value) return true if value == '1' return true if value == 'true' return false if value == '0' return false if value == 'false' end