Sha256: 56dc42f2491d3db8d336180c6dafbac6f7aff44c9bf4f223b0a9a4c88ee7a1d7

Contents?: true

Size: 823 Bytes

Versions: 8

Compression:

Stored size: 823 Bytes

Contents

# frozen_string_literal: true

module OoxmlParser
  # Class for working with any tag contained only value
  class ValuedChild < OOXMLDocumentObject
    # @return [String] value of tag
    attr_accessor :value
    # @return [String] type of value
    attr_reader :type

    def initialize(type = :string, parent: nil)
      @parent = parent
      @type = type
    end

    # Parse ValuedChild object
    # @param node [Nokogiri::XML:Element] node to parse
    # @return [ValuedChild] result of parsing
    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
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ooxml_parser-0.8.1 lib/ooxml_parser/common_parser/common_data/valued_child.rb
ooxml_parser-0.8.0 lib/ooxml_parser/common_parser/common_data/valued_child.rb
ooxml_parser-0.7.2 lib/ooxml_parser/common_parser/common_data/valued_child.rb
ooxml_parser-0.7.1 lib/ooxml_parser/common_parser/common_data/valued_child.rb
ooxml_parser-0.7.0 lib/ooxml_parser/common_parser/common_data/valued_child.rb
ooxml_parser-0.6.0 lib/ooxml_parser/common_parser/common_data/valued_child.rb
ooxml_parser-0.5.1 lib/ooxml_parser/common_parser/common_data/valued_child.rb
ooxml_parser-0.5.0 lib/ooxml_parser/common_parser/common_data/valued_child.rb