Class: Rucoa::Parser
- Inherits:
-
Object
- Object
- Rucoa::Parser
- Defined in:
- lib/rucoa/parser.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Rucoa::ParseResult
-
#initialize(text:, uri:) ⇒ Parser
constructor
A new instance of Parser.
Constructor Details
#initialize(text:, uri:) ⇒ Parser
Returns a new instance of Parser.
36 37 38 39 40 41 42 |
# File 'lib/rucoa/parser.rb', line 36 def initialize( text:, uri: ) @text = text @uri = uri end |
Class Method Details
.call(text:, uri:) ⇒ Rucoa::ParseResult
23 24 25 26 27 28 29 30 31 |
# File 'lib/rucoa/parser.rb', line 23 def call( text:, uri: ) new( text: text, uri: uri ).call end |
Instance Method Details
#call ⇒ Rucoa::ParseResult
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/rucoa/parser.rb', line 45 def call root_node, comments = parser.parse_with_comments( ::Parser::Source::Buffer.new( @uri, source: @text ) ) ParseResult.new( associations: ::Parser::Source::Comment.associate_locations( root_node, comments ), root_node: root_node ) rescue ::Parser::SyntaxError ParseResult.new(failed: true) end |