Class: JSGF::Alternation
- Inherits:
-
Object
- Object
- JSGF::Alternation
- 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.
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.
7 8 9 10 11 |
# File 'lib/jsgf/alternation.rb', line 7 def initialize(*args) @elements = args @optional = false @tags = [] end |
Instance Attribute Details
#elements ⇒ Object (readonly)
Returns the value of attribute elements.
3 4 5 |
# File 'lib/jsgf/alternation.rb', line 3 def elements @elements end |
#optional ⇒ Object
Returns the value of attribute optional.
4 5 6 |
# File 'lib/jsgf/alternation.rb', line 4 def optional @optional end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
5 6 7 |
# File 'lib/jsgf/alternation.rb', line 5 def @tags end |
Instance Method Details
#push(*args) ⇒ Object
13 14 15 |
# File 'lib/jsgf/alternation.rb', line 13 def push(*args) @elements.push *args end |
#size ⇒ Object
17 18 19 |
# File 'lib/jsgf/alternation.rb', line 17 def size @elements.size end |
#weights ⇒ Object
21 22 23 |
# File 'lib/jsgf/alternation.rb', line 21 def weights @elements.map {|a| a[:weight]} end |