class ReVIEW::Compiler::SyntaxElement
Attributes
name[R]
Public Class Methods
new(name, type, argc, esc, &block)
click to toggle source
# File lib/review/compiler.rb, line 471 def initialize(name, type, argc, esc, &block) @name = name @type = type @argc_spec = argc @esc_patterns = esc @checker = block end
Public Instance Methods
block_allowed?()
click to toggle source
# File lib/review/compiler.rb, line 515 def block_allowed? @type == :block or @type == :code_block or @type == :optional or @type == :optional_code_block end
block_required?()
click to toggle source
# File lib/review/compiler.rb, line 511 def block_required? @type == :block or @type == :code_block end
check_args(args)
click to toggle source
# File lib/review/compiler.rb, line 481 def check_args(args) unless @argc_spec === args.size raise ReVIEW::CompileError, "wrong # of parameters (block command //#{@name}, expect #{@argc_spec} but #{args.size})" end @checker.call(*args) if @checker end
code_block?()
click to toggle source
# File lib/review/compiler.rb, line 519 def code_block? @type == :code_block or @type == :optional_code_block end
min_argc()
click to toggle source
# File lib/review/compiler.rb, line 488 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
parse_args(args)
click to toggle source
# File lib/review/compiler.rb, line 497 def parse_args(args) if @esc_patterns args.map.with_index do |pattern, i| if @esc_patterns[i] args[i].__send__("to_#{@esc_patterns[i]}") else args[i].to_doc end end else args.map(&:to_doc) end end