Class: FuckItRuby::FuckProcessor
- Inherits:
-
AST::Processor
- Object
- AST::Processor
- FuckItRuby::FuckProcessor
- Defined in:
- lib/fuckitruby/fuck_processor.rb
Instance Attribute Summary collapse
-
#locations ⇒ Object
readonly
Returns the value of attribute locations.
Instance Method Summary collapse
- #handler_missing(node) ⇒ Object
-
#initialize(method_label, from, whole_file, *args) ⇒ FuckProcessor
constructor
A new instance of FuckProcessor.
- #mark_local(node) ⇒ Object (also: #on_lvar, #on_arg)
- #on_begin(node) ⇒ Object
- #on_def(node) ⇒ Object
- #on_lvasgn(node) ⇒ Object
- #on_send(node) ⇒ Object
Constructor Details
#initialize(method_label, from, whole_file, *args) ⇒ FuckProcessor
Returns a new instance of FuckProcessor.
7 8 9 10 11 12 13 |
# File 'lib/fuckitruby/fuck_processor.rb', line 7 def initialize(method_label, from, whole_file, *args) @method_label = method_label @from = from @whole_file = whole_file @locations = [] super *args end |
Instance Attribute Details
#locations ⇒ Object (readonly)
Returns the value of attribute locations.
5 6 7 |
# File 'lib/fuckitruby/fuck_processor.rb', line 5 def locations @locations end |
Instance Method Details
#handler_missing(node) ⇒ Object
19 20 21 |
# File 'lib/fuckitruby/fuck_processor.rb', line 19 def handler_missing(node) process_all(node.children.select { |c| c.is_a?(AST::Node) }) end |
#mark_local(node) ⇒ Object Also known as: on_lvar, on_arg
40 41 42 43 44 45 |
# File 'lib/fuckitruby/fuck_processor.rb', line 40 def mark_local(node) if (@whole_file || @itshappening) && node.children[0] == @from @locations << [node.location.expression.begin_pos, node.location.expression.end_pos] end node end |
#on_begin(node) ⇒ Object
15 16 17 |
# File 'lib/fuckitruby/fuck_processor.rb', line 15 def on_begin(node) process_all node end |
#on_def(node) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/fuckitruby/fuck_processor.rb', line 23 def on_def(node) if !@whole_file && node.children[0] == @method_label @itshappening = true node.children[1..-1].each &method(:process) @itshappening = false elsif @whole_file && node.children[0] == @from @locations << [node.location.name.begin_pos, node.location.name.end_pos] node.children[1..-1].each &method(:process) end end |
#on_lvasgn(node) ⇒ Object
34 35 36 37 38 |
# File 'lib/fuckitruby/fuck_processor.rb', line 34 def on_lvasgn(node) if (@whole_file || @itshappening) && node.children[0] == @from @locations << [node.location.name.begin_pos, node.location.name.end_pos] end end |
#on_send(node) ⇒ Object
50 51 52 53 54 |
# File 'lib/fuckitruby/fuck_processor.rb', line 50 def on_send(node) if (@whole_file || @itshappening) && node.children[1] == @from #&& node.children[0].nil? @locations << [node.location.selector.begin_pos, node.location.selector.end_pos] end end |