Class: Pbt::Check::RSpecAdapter::PredicateBlockInspector
- Inherits:
-
Prism::Visitor
- Object
- Prism::Visitor
- Pbt::Check::RSpecAdapter::PredicateBlockInspector
- Defined in:
- lib/pbt/check/rspec_adapter/predicate_block_inspector.rb
Overview
Instance Attribute Summary collapse
-
#method_body ⇒ Object
readonly
This class is used to get user-defined block code.
-
#method_params ⇒ Object
readonly
This class is used to get user-defined block code.
Instance Method Summary collapse
-
#initialize(line) ⇒ PredicateBlockInspector
constructor
A new instance of PredicateBlockInspector.
- #visit_call_node(node) ⇒ Object
Constructor Details
#initialize(line) ⇒ PredicateBlockInspector
Returns a new instance of PredicateBlockInspector.
30 31 32 33 34 |
# File 'lib/pbt/check/rspec_adapter/predicate_block_inspector.rb', line 30 def initialize(line) @line = line @method_body = nil super() end |
Instance Attribute Details
#method_body ⇒ Object (readonly)
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/pbt/check/rspec_adapter/predicate_block_inspector.rb', line 27 class PredicateBlockInspector < Prism::Visitor attr_reader :method_body, :method_params def initialize(line) @line = line @method_body = nil super() end def visit_call_node(node) if node.name == :property && node.block.opening_loc.start_line == @line @method_params = node.block.parameters.parameters.slice @method_body = node.block.body.slice end super end end |
#method_params ⇒ Object (readonly)
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/pbt/check/rspec_adapter/predicate_block_inspector.rb', line 27 class PredicateBlockInspector < Prism::Visitor attr_reader :method_body, :method_params def initialize(line) @line = line @method_body = nil super() end def visit_call_node(node) if node.name == :property && node.block.opening_loc.start_line == @line @method_params = node.block.parameters.parameters.slice @method_body = node.block.body.slice end super end end |
Instance Method Details
#visit_call_node(node) ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/pbt/check/rspec_adapter/predicate_block_inspector.rb', line 36 def visit_call_node(node) if node.name == :property && node.block.opening_loc.start_line == @line @method_params = node.block.parameters.parameters.slice @method_body = node.block.body.slice end super end |