Class: Openapi3Parser::Node::Array

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable
Defined in:
lib/openapi3_parser/node/array.rb

Overview

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.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, context) ⇒ Array

Returns a new instance of Array.

Parameters:

  • data (::Array)

    data used to populate this node

  • context (Context)

    The context of this node in the document



24
25
26
27
# File 'lib/openapi3_parser/node/array.rb', line 24

def initialize(data, context)
  @node_data = data
  @node_context = context
end

Instance Attribute Details

#node_contextObject (readonly)

Returns the value of attribute node_context.



20
21
22
# File 'lib/openapi3_parser/node/array.rb', line 20

def node_context
  @node_context
end

#node_dataObject (readonly)

Returns the value of attribute node_data.



20
21
22
# File 'lib/openapi3_parser/node/array.rb', line 20

def node_data
  @node_data
end

Instance Method Details

#inspectString

Returns:

  • (String)


38
39
40
41
# File 'lib/openapi3_parser/node/array.rb', line 38

def inspect
  fragment = node_context.document_location.pointer.fragment
  %{#{self.class.name}(#{fragment})}
end

#node_at(pointer_like) ⇒ Object

Used to access a node relative to this node

Parameters:

Returns:

  • anything



32
33
34
35
# File 'lib/openapi3_parser/node/array.rb', line 32

def node_at(pointer_like)
  current_pointer = node_context.document_location.pointer
  node_context.document.node_at(pointer_like, current_pointer)
end