Class: TermUtils::AP::Level
- Defined in:
- lib/term_utils/ap/level.rb
Overview
Represents an argument list subset. It must lead with a Flag. It has its own syntax.
Instance Attribute Summary collapse
Attributes inherited from Element
#flags, #id, #max_occurs, #min_occurs
Instance Method Summary collapse
-
#define_syntax(&block) ⇒ TermUtils::AP::Syntax
Defines the syntax.
-
#finalize!(opts = {}) ⇒ nil
Finalizes this one.
-
#initialize(opts = {}) ⇒ Level
constructor
Constructs a new Level.
-
#initialize_dup(other) ⇒ Object
For dup method.
Methods inherited from Element
#define_flag, #flagged?, #multiple_occurs?, #occur_bounded?
Constructor Details
#initialize(opts = {}) ⇒ Level
Constructs a new Level.
30 31 32 33 34 35 36 |
# File 'lib/term_utils/ap/level.rb', line 30 def initialize(opts = {}) @id = opts.fetch(:id, nil) @min_occurs = opts.fetch(:min_occurs, 0) @max_occurs = opts.fetch(:max_occurs, 1) @flags = [] @syntax = TermUtils::AP::Syntax.new end |
Instance Attribute Details
#syntax ⇒ TermUtils::AP::Syntax
24 25 26 |
# File 'lib/term_utils/ap/level.rb', line 24 def syntax @syntax end |
Instance Method Details
#define_syntax(&block) ⇒ TermUtils::AP::Syntax
Defines the syntax.
51 52 53 54 |
# File 'lib/term_utils/ap/level.rb', line 51 def define_syntax(&block) block.call(@syntax) if block @syntax end |
#finalize!(opts = {}) ⇒ nil
Finalizes this one. Internal use.
44 45 46 47 48 |
# File 'lib/term_utils/ap/level.rb', line 44 def finalize!(opts = {}) super raise TermUtils::AP::SyntaxError, "level must contain at least one flag" if @flags.empty? @syntax.finalize!(opts) end |
#initialize_dup(other) ⇒ Object
For dup method.
38 39 40 41 |
# File 'lib/term_utils/ap/level.rb', line 38 def initialize_dup(other) @syntax = other.syntax.dup super end |