Class: LibRubyParser::Nodes::MatchCurrentLine
- Inherits:
-
LibRubyParser::Node
- Object
- LibRubyParser::Node
- LibRubyParser::Nodes::MatchCurrentLine
- 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
-
#expression_l ⇒ Loc
readonly
Location of the regex.
-
#re ⇒ Node
readonly
Given regex.
Instance Attribute Details
#expression_l ⇒ Loc (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.
2674 2675 2676 |
# File 'lib/lib-ruby-parser/nodes.rb', line 2674 def expression_l @expression_l end |
#re ⇒ Node (readonly)
Given regex
2662 2663 2664 |
# File 'lib/lib-ruby-parser/nodes.rb', line 2662 def re @re end |