Class: Querly::Script
- Inherits:
-
Object
- Object
- Querly::Script
- Defined in:
- lib/querly/script.rb
Defined Under Namespace
Classes: Builder
Instance Attribute Summary collapse
-
#node ⇒ Object
readonly
Returns the value of attribute node.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(path:, node:) ⇒ Script
constructor
A new instance of Script.
- #root_pair ⇒ Object
Constructor Details
#initialize(path:, node:) ⇒ Script
Returns a new instance of Script.
16 17 18 19 |
# File 'lib/querly/script.rb', line 16 def initialize(path:, node:) @path = path @node = node end |
Instance Attribute Details
#node ⇒ Object (readonly)
Returns the value of attribute node.
4 5 6 |
# File 'lib/querly/script.rb', line 4 def node @node end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/querly/script.rb', line 3 def path @path end |
Class Method Details
.load(path:, source:) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/querly/script.rb', line 6 def self.load(path:, source:) parser = Parser::Ruby25.new(Builder.new).tap do |parser| parser.diagnostics.all_errors_are_fatal = true parser.diagnostics.ignore_warnings = true end buffer = Parser::Source::Buffer.new(path.to_s, 1) buffer.source = source self.new(path: path, node: parser.parse(buffer)) end |