Class: Peruby::Op::RegexpLiteral
Overview
Compiled qr// value.
Instance Method Summary collapse
-
#initialize(quote) ⇒ RegexpLiteral
constructor
A new instance of RegexpLiteral.
- #match_on(cell, env, context) ⇒ Object
- #run(env, context) ⇒ Object
Methods inherited from Base
#argument_cells, #local_slot, #lvalue, #run_subroutine, #to_callable, #warning_directive?
Constructor Details
#initialize(quote) ⇒ RegexpLiteral
Returns a new instance of RegexpLiteral.
161 162 163 |
# File 'lib/peruby/op/regexp.rb', line 161 def initialize(quote) @quote = quote end |
Instance Method Details
#match_on(cell, env, context) ⇒ Object
170 171 172 |
# File 'lib/peruby/op/regexp.rb', line 170 def match_on(cell, env, context) Match.new(@quote).match_on(cell, env, context) end |
#run(env, context) ⇒ Object
165 166 167 168 |
# File 'lib/peruby/op/regexp.rb', line 165 def run(env, context) value = Ref.new(RegexpCompiler.compile(Interpolation.pattern(@quote, env), @quote.modifiers)) context == :list ? [Scalar.new(value)] : value end |