Class: ReVIEW::Compiler::SyntaxElement
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #block_allowed? ⇒ Boolean
- #block_required? ⇒ Boolean
- #check_args(args) ⇒ Object
-
#initialize(name, type, argc, &block) ⇒ SyntaxElement
constructor
A new instance of SyntaxElement.
- #min_argc ⇒ Object
- #minicolumn? ⇒ Boolean
Constructor Details
#initialize(name, type, argc, &block) ⇒ SyntaxElement
Returns a new instance of SyntaxElement.
66 67 68 69 70 71 |
# File 'lib/review/compiler.rb', line 66 def initialize(name, type, argc, &block) @name = name @type = type @argc_spec = argc @checker = block end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
73 74 75 |
# File 'lib/review/compiler.rb', line 73 def name @name end |
Instance Method Details
#block_allowed? ⇒ Boolean
102 103 104 |
# File 'lib/review/compiler.rb', line 102 def block_allowed? @type == :block or @type == :optional or @type == :minicolumn end |
#block_required? ⇒ Boolean
98 99 100 |
# File 'lib/review/compiler.rb', line 98 def block_required? @type == :block or @type == :minicolumn end |
#check_args(args) ⇒ Object
75 76 77 78 79 80 81 82 83 |
# File 'lib/review/compiler.rb', line 75 def check_args(args) unless @argc_spec === args.size # rubocop:disable Style/CaseEquality raise CompileError, "wrong # of parameters (block command //#{@name}, expect #{@argc_spec} but #{args.size})" end if @checker @checker.call(*args) end end |
#min_argc ⇒ Object
85 86 87 88 89 90 91 92 |
# File 'lib/review/compiler.rb', line 85 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 |
#minicolumn? ⇒ Boolean
94 95 96 |
# File 'lib/review/compiler.rb', line 94 def minicolumn? @type == :minicolumn end |