Class: LibRubyParser::Nodes::MatchCurrentLine

Inherits:
LibRubyParser::Node show all
Defined in:
lib/lib-ruby-parser/nodes.rb

Overview

Represents implicit matching using if /regex/

if /.*/
puts 'true'
else
puts 'false'
end

Prints "false".

Under the hood this construction matches regex against $_, so the following works:

$_ = 'match_me'
if /match_me/
puts 'true'
else
puts 'false'
end

this code prints "true".

Instance Attribute Summary collapse

Instance Attribute Details

#expression_lLoc (readonly)

Location of the regex

if /re/; end
   ~~~~

Technically this location is redundant, but keeping it is the only way to have the same interface for all nodes.

Returns:



2674
2675
2676
# File 'lib/lib-ruby-parser/nodes.rb', line 2674

def expression_l
  @expression_l
end

#reNode (readonly)

Given regex

Returns:



2662
2663
2664
# File 'lib/lib-ruby-parser/nodes.rb', line 2662

def re
  @re
end