Class: Solargraph::Rspec::Walker
- Inherits:
-
Object
- Object
- Solargraph::Rspec::Walker
- Defined in:
- lib/solargraph/rspec/walker.rb
Defined Under Namespace
Classes: Hook, ParsingError
Instance Attribute Summary collapse
-
#ast ⇒ Object
readonly
Returns the value of attribute ast.
-
#comments ⇒ Object
readonly
Returns the value of attribute comments.
Instance Method Summary collapse
-
#initialize(ast, comments = {}) ⇒ Walker
constructor
A new instance of Walker.
- #on(node_type, args = [], &block) ⇒ Object
- #walk ⇒ Object
Constructor Details
#initialize(ast, comments = {}) ⇒ Walker
Returns a new instance of Walker.
71 72 73 74 75 |
# File 'lib/solargraph/rspec/walker.rb', line 71 def initialize(ast, comments = {}) @comments = comments @ast = ast @hooks = Hash.new([]) end |
Instance Attribute Details
#ast ⇒ Object (readonly)
Returns the value of attribute ast.
67 68 69 |
# File 'lib/solargraph/rspec/walker.rb', line 67 def ast @ast end |
#comments ⇒ Object (readonly)
Returns the value of attribute comments.
67 68 69 |
# File 'lib/solargraph/rspec/walker.rb', line 67 def comments @comments end |
Instance Method Details
#on(node_type, args = [], &block) ⇒ Object
77 78 79 |
# File 'lib/solargraph/rspec/walker.rb', line 77 def on(node_type, args = [], &block) @hooks[node_type] << Hook.new(node_type, args, &block) end |
#walk ⇒ Object
81 82 83 |
# File 'lib/solargraph/rspec/walker.rb', line 81 def walk @ast.is_a?(Array) ? @ast.each { |node| traverse(node) } : traverse(@ast) end |