Class: Openapi3Parser::Source::Location
- Inherits:
-
Object
- Object
- Openapi3Parser::Source::Location
- Extended by:
- Forwardable
- Defined in:
- lib/openapi3_parser/source/location.rb
Overview
Class used to represent a location within an OpenAPI document. It contains a source, which is the source file/data used for the contents and the pointer which indicates where in the object like file the data is
Instance Attribute Summary collapse
-
#pointer ⇒ Object
readonly
Returns the value of attribute pointer.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #data ⇒ Object
-
#initialize(source, pointer_segments) ⇒ Location
constructor
A new instance of Location.
- #inspect ⇒ Object
- #pointer_defined? ⇒ Boolean
- #source_available? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
Instance Attribute Details
#pointer ⇒ Object (readonly)
Returns the value of attribute pointer.
18 19 20 |
# File 'lib/openapi3_parser/source/location.rb', line 18 def pointer @pointer end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
18 19 20 |
# File 'lib/openapi3_parser/source/location.rb', line 18 def source @source end |
Class Method Details
.next_field(location, field) ⇒ Object
13 14 15 |
# File 'lib/openapi3_parser/source/location.rb', line 13 def self.next_field(location, field) new(location.source, location.pointer.segments + [field]) end |
Instance Method Details
#==(other) ⇒ Object
27 28 29 30 31 |
# File 'lib/openapi3_parser/source/location.rb', line 27 def ==(other) return false unless other.instance_of?(self.class) source == other.source && pointer == other.pointer end |
#data ⇒ Object
37 38 39 |
# File 'lib/openapi3_parser/source/location.rb', line 37 def data source.data_at_pointer(pointer.segments) end |
#inspect ⇒ Object
49 50 51 |
# File 'lib/openapi3_parser/source/location.rb', line 49 def inspect %{#{self.class.name}(source: #{source.inspect}, pointer: #{pointer})} end |
#pointer_defined? ⇒ Boolean
41 42 43 |
# File 'lib/openapi3_parser/source/location.rb', line 41 def pointer_defined? source.has_pointer?(pointer.segments) end |
#source_available? ⇒ Boolean
45 46 47 |
# File 'lib/openapi3_parser/source/location.rb', line 45 def source_available? source.available? end |
#to_s ⇒ Object
33 34 35 |
# File 'lib/openapi3_parser/source/location.rb', line 33 def to_s source.relative_to_root + pointer.fragment end |