class ReVIEW::Compiler::SyntaxElement
Attributes
name[R]
Public Class Methods
new(name, type, argc, &block)
click to toggle source
# File lib/review/compiler.rb, line 56 def initialize(name, type, argc, &block) @name = name @type = type @argc_spec = argc @checker = block end
Public Instance Methods
block_allowed?()
click to toggle source
# File lib/review/compiler.rb, line 85 def block_allowed? @type == :block or @type == :optional end
block_required?()
click to toggle source
# File lib/review/compiler.rb, line 81 def block_required? @type == :block end
check_args(args)
click to toggle source
# File lib/review/compiler.rb, line 65 def check_args(args) unless @argc_spec === args.size raise CompileError, "wrong # of parameters (block command //#{@name}, expect #{@argc_spec} but #{args.size})" end @checker.call(*args) if @checker end
min_argc()
click to toggle source
# File lib/review/compiler.rb, line 72 def min_argc case @argc_spec when Range then @argc_spec.begin when Integer then @argc_spec else raise TypeError, "argc_spec is not Range/Integer: #{inspect()}" end end