class Openapi3Parser::Node::Array

An array within a OpenAPI document. Very similar to a normal Ruby array, however this is read only and knows the context of where it sits in an OpenAPI document

The contents of the data will be dependent on where this document is in the document hierachy.

Attributes

node_context[R]
node_data[R]

Public Class Methods

new(data, context) click to toggle source

@param [::Array] data data used to populate this node @param [Context] context The context of this node in the document

# File lib/openapi3_parser/node/array.rb, line 22
def initialize(data, context)
  @node_data = data
  @node_context = context
end

Public Instance Methods

==(other) click to toggle source

@param [Any] other

@return [Boolean]

# File lib/openapi3_parser/node/array.rb, line 41
def ==(other)
  other.instance_of?(self.class) &&
    node_context.same_data_and_source?(other.node_context)
end
[](index) click to toggle source
# File lib/openapi3_parser/node/array.rb, line 27
def [](index)
  Placeholder.resolve(node_data[index])
end
each(&block) click to toggle source

Iterates through the data of this node, used by Enumerable

@return [Object]

# File lib/openapi3_parser/node/array.rb, line 34
def each(&block)
  Placeholder.each(node_data, &block)
end
inspect() click to toggle source

@return [String]

# File lib/openapi3_parser/node/array.rb, line 55
def inspect
  fragment = node_context.document_location.pointer.fragment
  %{#{self.class.name}(#{fragment})}
end
node_at(pointer_like) click to toggle source

Used to access a node relative to this node @param [Source::Pointer, ::Array, ::String] pointer_like @return anything

# File lib/openapi3_parser/node/array.rb, line 49
def node_at(pointer_like)
  current_pointer = node_context.document_location.pointer
  node_context.document.node_at(pointer_like, current_pointer)
end