Class: Openapi3Parser::Node::Array
- Inherits:
-
Object
- Object
- Openapi3Parser::Node::Array
- 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
-
#node_context ⇒ Object
readonly
Returns the value of attribute node_context.
-
#node_data ⇒ Object
readonly
Returns the value of attribute node_data.
Instance Method Summary collapse
- #==(other) ⇒ Boolean
- #[](index) ⇒ Object
-
#each ⇒ Object
Iterates through the data of this node, used by Enumerable.
-
#initialize(data, context) ⇒ Array
constructor
A new instance of Array.
- #inspect ⇒ String
-
#node_at(pointer_like) ⇒ Object
Used to access a node relative to this node.
Constructor Details
#initialize(data, context) ⇒ Array
Returns a new instance of Array.
22 23 24 25 |
# File 'lib/openapi3_parser/node/array.rb', line 22 def initialize(data, context) @node_data = data @node_context = context end |
Instance Attribute Details
#node_context ⇒ Object (readonly)
Returns the value of attribute node_context.
18 19 20 |
# File 'lib/openapi3_parser/node/array.rb', line 18 def node_context @node_context end |
#node_data ⇒ Object (readonly)
Returns the value of attribute node_data.
18 19 20 |
# File 'lib/openapi3_parser/node/array.rb', line 18 def node_data @node_data end |
Instance Method Details
#==(other) ⇒ Boolean
41 42 43 44 |
# 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) ⇒ Object
27 28 29 |
# File 'lib/openapi3_parser/node/array.rb', line 27 def [](index) Placeholder.resolve(node_data[index]) end |
#each ⇒ Object
Iterates through the data of this node, used by Enumerable
34 35 36 |
# File 'lib/openapi3_parser/node/array.rb', line 34 def each(&) Placeholder.each(node_data, &) end |
#inspect ⇒ String
55 56 57 58 |
# 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) ⇒ Object
Used to access a node relative to this node
49 50 51 52 |
# 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 |