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 = []) {|, | ... } ⇒ Object
- #walk ⇒ Object
Constructor Details
#initialize(ast, comments = {}) ⇒ Walker
Returns a new instance of Walker.
75 76 77 78 79 |
# File 'lib/solargraph/rspec/walker.rb', line 75 def initialize(ast, comments = {}) @comments = comments @ast = ast @hooks = Hash.new { |h, k| h[k] = [] } end |
Instance Attribute Details
#ast ⇒ Object (readonly)
Returns the value of attribute ast.
71 72 73 |
# File 'lib/solargraph/rspec/walker.rb', line 71 def ast @ast end |
#comments ⇒ Object (readonly)
Returns the value of attribute comments.
71 72 73 |
# File 'lib/solargraph/rspec/walker.rb', line 71 def comments @comments end |
Instance Method Details
#on(node_type, args = []) {|, | ... } ⇒ Object
83 84 85 |
# File 'lib/solargraph/rspec/walker.rb', line 83 def on(node_type, args = [], &block) @hooks[node_type] << Hook.new(node_type, args, &block) end |
#walk ⇒ Object
87 88 89 |
# File 'lib/solargraph/rspec/walker.rb', line 87 def walk @ast.is_a?(Array) ? @ast.each { |node| traverse(node) } : traverse(@ast) end |