Class: JSGF::Alternation

Inherits:
Object
  • Object
show all
Defined in:
lib/jsgf/alternation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#elementsObject (readonly)

Returns the value of attribute elements.



3
4
5
# File 'lib/jsgf/alternation.rb', line 3

def elements
  @elements
end

#optionalObject

Returns the value of attribute optional.



4
5
6
# File 'lib/jsgf/alternation.rb', line 4

def optional
  @optional
end

#tagsObject (readonly)

Returns the value of attribute tags.



5
6
7
# File 'lib/jsgf/alternation.rb', line 5

def tags
  @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

#sizeObject



17
18
19
# File 'lib/jsgf/alternation.rb', line 17

def size
    @elements.size
end

#weightsObject



21
22
23
# File 'lib/jsgf/alternation.rb', line 21

def weights
    @elements.map {|a| a[:weight]}
end