class Extract::ValueBuilder

Public Instance Methods

value() click to toggle source
# File lib/src/extract/value_builder.rb, line 13
def value
  props = node.props
  case props
  when String then value_for_string
  when Array then value_for_array
  when Hash then value_for_hash
  else
    raise "Invalid kind #{props.class} (#{props})"
  end
end

Private Instance Methods

value_for_array() click to toggle source
# File lib/src/extract/value_builder.rb, line 44
def value_for_array
  ArrayValue.new(node, extractor).value
end
value_for_hash() click to toggle source
# File lib/src/extract/value_builder.rb, line 26
def value_for_hash
  props = node.props
  
  Unescape.new(node, extractor).unescape! if props[:unescape]

  fixed_value = props[:fixed]
  return fixed_value if fixed_value
  return ArrayOf.new(node, extractor).value if props[:array_of]
  return Within.new(node, extractor).value if props[:within]
  return StringValue.new(node, extractor).value if (props.keys & %i[path attr]).any?

  HashBuilder.new(node, extractor).value
end
value_for_string() click to toggle source
# File lib/src/extract/value_builder.rb, line 40
def value_for_string
  StringValue.new(Node.new({ path: node.props }, node.path), extractor).value
end