Class: JSGF::Alternation
- Inherits:
-
Object
- Object
- JSGF::Alternation
- Includes:
- Enumerable
- Defined in:
- lib/jsgf/alternation.rb
Instance Attribute Summary collapse
-
#elements ⇒ Object
readonly
Returns the value of attribute elements.
-
#optional ⇒ Object
Returns the value of attribute optional.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
Enumerable collapse
Instance Method Summary collapse
-
#initialize(*args) ⇒ Alternation
constructor
A new instance of Alternation.
- #push(*args) ⇒ Object
- #size ⇒ Object
- #weights ⇒ Object
Constructor Details
#initialize(*args) ⇒ Alternation
Returns a new instance of Alternation.
9 10 11 12 13 |
# File 'lib/jsgf/alternation.rb', line 9 def initialize(*args) @elements = args @optional = false @tags = [] end |
Instance Attribute Details
#elements ⇒ Object (readonly)
Returns the value of attribute elements.
5 6 7 |
# File 'lib/jsgf/alternation.rb', line 5 def elements @elements end |
#optional ⇒ Object
Returns the value of attribute optional.
6 7 8 |
# File 'lib/jsgf/alternation.rb', line 6 def optional @optional end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
7 8 9 |
# File 'lib/jsgf/alternation.rb', line 7 def @tags end |
Instance Method Details
#each(*args, &block) ⇒ Object
16 17 18 |
# File 'lib/jsgf/alternation.rb', line 16 def each(*args, &block) elements.each(*args, &block) end |
#push(*args) ⇒ Object
21 22 23 |
# File 'lib/jsgf/alternation.rb', line 21 def push(*args) @elements.push *args end |
#size ⇒ Object
25 26 27 |
# File 'lib/jsgf/alternation.rb', line 25 def size @elements.size end |
#weights ⇒ Object
29 30 31 |
# File 'lib/jsgf/alternation.rb', line 29 def weights @elements.map {|a| a[:weight]} end |