Class: Liquidscript::Compiler::Base::Action

Inherits:
Object
  • Object
show all
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

Instance Method Details

#end_loopProc

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).

Returns:

  • (Proc)


33
34
35
# File 'lib/liquidscript/compiler/base/action.rb', line 33

def end_loop
  @_end_loop ||= proc { |_| false }
end

#nothingProc

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).

Returns:

  • (Proc)


14
15
16
# File 'lib/liquidscript/compiler/base/action.rb', line 14

def nothing
  @_nothing ||= proc { true }
end

#shiftProc

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.

Returns:

  • (Proc)


24
25
26
# File 'lib/liquidscript/compiler/base/action.rb', line 24

def shift
  @_shift ||= proc { |_| _ }
end