Class: Liquidscript::Compiler::Base::Action
- Inherits:
-
Object
- Object
- Liquidscript::Compiler::Base::Action
- Defined in:
- lib/liquidscript/compiler/base/action.rb
Overview
Used to construct blocks that are used with Helpers#expect. It’s primarily syntaxic sugar, and DRYness.
Instance Method Summary collapse
-
#end_loop ⇒ Proc
Returns a block that returns false, and takes one argument.
-
#nothing ⇒ Proc
Returns a block that returns true, and takes no arguments.
-
#shift ⇒ Proc
Returns a block that returns the first argument given to it.
Instance Method Details
#end_loop ⇒ Proc
Returns a block that returns false, and takes one argument. This is for Helpers#expect, when you want to shift the token, and you want the loop to end (if applicable).
33 34 35 |
# File 'lib/liquidscript/compiler/base/action.rb', line 33 def end_loop @_end_loop ||= proc { |_| false } end |
#nothing ⇒ Proc
Returns a block that returns true, and takes no arguments. This is for Helpers#expect, when you don’t want the token to be shifted, and you don’t want the loop to end (if applicable).
14 15 16 |
# File 'lib/liquidscript/compiler/base/action.rb', line 14 def nothing @_nothing ||= proc { true } end |
#shift ⇒ Proc
Returns a block that returns the first argument given to it. This is for Helpers#expect, when you want to shift the token, and you don’t want the loop to end (if applicable). Also used internally for Helpers#shift.
24 25 26 |
# File 'lib/liquidscript/compiler/base/action.rb', line 24 def shift @_shift ||= proc { |_| _ } end |