Sha256: a4e140321607af18d1cbb9a7d54603a79575b1e94b832594c473b9ec604cdf76

Contents?: true

Size: 739 Bytes

Versions: 4

Compression:

Stored size: 739 Bytes

Contents

module Extract
  class StringValue < Base
    def value
      path = node[:props][:path]
      return formatted_array_values(path) if path.is_a?(Array)

      extract_value(node)
    end

    private

    def extract_value(node_to_extract)
      extractor.extract(node_to_extract)
    end

    def formatted_array_values(paths)
      extractor.format_value(values_from_array(paths), node[:props])
    end

    def values_from_array(paths)
      node_path = node.path

      paths.map do |inner|
        if inner.is_a?(String)
          extract_value(Node.new({ path: inner, link: node[:props][:link] }, node_path))
        else
          StringValue.new(Node.new(inner, node_path), extractor).value
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
xml_data_extractor-0.5.0 lib/src/extract/string_value.rb
xml_data_extractor-0.4.0 lib/src/extract/string_value.rb
xml_data_extractor-0.3.0 lib/src/extract/string_value.rb
xml_data_extractor-0.2.0 lib/src/extract/string_value.rb