Class: Rucoa::Source
- Inherits:
-
Object
- Object
- Rucoa::Source
- Defined in:
- lib/rucoa/source.rb
Instance Attribute Summary collapse
- #content ⇒ String readonly
- #uri ⇒ String readonly
Instance Method Summary collapse
- #definitions ⇒ Array<Rucoa::Definition::Base>
- #failed_to_parse? ⇒ Boolean
-
#initialize(content:, uri:) ⇒ Source
constructor
A new instance of Source.
- #name ⇒ String?
- #node_at(position) ⇒ Rucoa::Nodes::Base?
- #root_node ⇒ Rucoa::Nodes::Base?
- #untitled? ⇒ Boolean
Constructor Details
#initialize(content:, uri:) ⇒ Source
Returns a new instance of Source.
15 16 17 18 19 20 21 |
# File 'lib/rucoa/source.rb', line 15 def initialize( content:, uri: ) @content = content @uri = uri end |
Instance Attribute Details
#content ⇒ String (readonly)
8 9 10 |
# File 'lib/rucoa/source.rb', line 8 def content @content end |
#uri ⇒ String (readonly)
11 12 13 |
# File 'lib/rucoa/source.rb', line 11 def uri @uri end |
Instance Method Details
#definitions ⇒ Array<Rucoa::Definition::Base>
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/rucoa/source.rb', line 53 def definitions @definitions ||= if parse_result.failed? || root_node.nil? [] else Yard::DefinitionsLoader.call( associations: parse_result.associations, root_node: parse_result.root_node ) end end |
#failed_to_parse? ⇒ Boolean
66 67 68 |
# File 'lib/rucoa/source.rb', line 66 def failed_to_parse? parse_result.failed? end |
#name ⇒ String?
83 84 85 86 87 88 89 |
# File 'lib/rucoa/source.rb', line 83 def name if untitled? uri_object.opaque else uri_object.path end end |
#node_at(position) ⇒ Rucoa::Nodes::Base?
93 94 95 96 97 |
# File 'lib/rucoa/source.rb', line 93 def node_at(position) root_and_descendant_nodes.reverse.find do |node| node.include_position?(position) end end |
#root_node ⇒ Rucoa::Nodes::Base?
100 101 102 |
# File 'lib/rucoa/source.rb', line 100 def root_node parse_result.root_node end |
#untitled? ⇒ Boolean
105 106 107 |
# File 'lib/rucoa/source.rb', line 105 def untitled? uri_object.scheme == 'untitled' end |