Class: Openapi3Parser::Node::Object
- Inherits:
-
Object
- Object
- Openapi3Parser::Node::Object
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Defined in:
- lib/openapi3_parser/node/object.rb
Direct Known Subclasses
Components, Contact, Discriminator, Encoding, Example, ExternalDocumentation, Header, Info, License, Link, MediaType, OauthFlow, OauthFlows, Openapi, Operation, Parameter, PathItem, RequestBody, Response, Schema, SecurityScheme, Server, ServerVariable, Tag, Xml
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
-
#[](value) ⇒ Object
Look up an attribute of the node by the name it has in the OpenAPI document.
-
#each ⇒ Object
Iterates through the data of this node, used by Enumerable.
-
#extension(value) ⇒ Hash, ...
Look up an extension provided for this object, doesn’t need a prefix of “x-”.
-
#initialize(data, context) ⇒ Object
constructor
A new instance of Object.
- #inspect ⇒ String
-
#node_at(pointer_like) ⇒ Object
Used to access a node relative to this node.
-
#render_markdown(value) ⇒ String?
Used to render fields that can be in markdown syntax into HTML.
-
#values ⇒ Array
Provide an array of values for this object, a partner to the #keys method.
Constructor Details
#initialize(data, context) ⇒ Object
Returns a new instance of Object.
14 15 16 17 |
# File 'lib/openapi3_parser/node/object.rb', line 14 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.
12 13 14 |
# File 'lib/openapi3_parser/node/object.rb', line 12 def node_context @node_context end |
#node_data ⇒ Object (readonly)
Returns the value of attribute node_data.
12 13 14 |
# File 'lib/openapi3_parser/node/object.rb', line 12 def node_data @node_data end |
Instance Method Details
#==(other) ⇒ Boolean
54 55 56 57 |
# File 'lib/openapi3_parser/node/object.rb', line 54 def ==(other) other.instance_of?(self.class) && node_context.same_data_and_source?(other.node_context) end |
#[](value) ⇒ Object
Look up an attribute of the node by the name it has in the OpenAPI document.
34 35 36 |
# File 'lib/openapi3_parser/node/object.rb', line 34 def [](value) Placeholder.resolve(node_data[value.to_s]) end |
#each ⇒ Object
Iterates through the data of this node, used by Enumerable
62 63 64 |
# File 'lib/openapi3_parser/node/object.rb', line 62 def each(&) Placeholder.each(node_data, &) end |
#extension(value) ⇒ Hash, ...
Look up an extension provided for this object, doesn’t need a prefix of “x-”
47 48 49 |
# File 'lib/openapi3_parser/node/object.rb', line 47 def extension(value) self["x-#{value}"] end |
#inspect ⇒ String
99 100 101 102 |
# File 'lib/openapi3_parser/node/object.rb', line 99 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
93 94 95 96 |
# File 'lib/openapi3_parser/node/object.rb', line 93 def node_at(pointer_like) current_pointer = node_context.document_location.pointer node_context.document.node_at(pointer_like, current_pointer) end |
#render_markdown(value) ⇒ String?
Used to render fields that can be in markdown syntax into HTML
77 78 79 80 81 |
# File 'lib/openapi3_parser/node/object.rb', line 77 def render_markdown(value) return if value.nil? Markdown.to_html(value) end |
#values ⇒ Array
Provide an array of values for this object, a partner to the #keys method
70 71 72 |
# File 'lib/openapi3_parser/node/object.rb', line 70 def values map(&:last) end |