Sha256: 85a08d596f5b855260a29f6e354a2da02885d47a6f92e25de9ab5177fe4f15a4

Contents?: true

Size: 443 Bytes

Versions: 5

Compression:

Stored size: 443 Bytes

Contents

class Node < Struct.new(:props, :path)
  def initialize(*)
    super
    self.path ||= ""
  end

  def first_only?
    return unless props.is_a? Hash

    props[:array_presence] == "first_only"
  end

  def array_of_paths
    array_paths(props[:array_of])
  end

  private

  def array_paths(array_props)
    if array_props.is_a?(Hash)
      array_props.values_at(:path, :link, :uniq_by)
    else
      [array_props].flatten
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
xml_data_extractor-0.5.0 lib/src/node.rb
xml_data_extractor-0.4.0 lib/src/node.rb
xml_data_extractor-0.3.0 lib/src/node.rb
xml_data_extractor-0.2.0 lib/src/node.rb
xml_data_extractor-0.1.0 lib/src/node.rb