Sha256: 3498fea7680e693420d30e72977c1e21e9f008a69aeb7891b083861ad73b8c11

Contents?: true

Size: 474 Bytes

Versions: 2

Compression:

Stored size: 474 Bytes

Contents

# frozen_string_literal: true

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

2 entries across 2 versions & 1 rubygems

Version Path
xml_data_extractor-0.7.0 lib/src/node.rb
xml_data_extractor-0.6.0 lib/src/node.rb