Class: JSGF::Alternation

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

Instance Attribute Summary collapse

Enumerable collapse

Instance Method Summary collapse

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

#elementsObject (readonly)

Returns the value of attribute elements.



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

def elements
  @elements
end

#optionalObject

Returns the value of attribute optional.



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

def optional
  @optional
end

#tagsObject (readonly)

Returns the value of attribute tags.



7
8
9
# File 'lib/jsgf/alternation.rb', line 7

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

#sizeObject



25
26
27
# File 'lib/jsgf/alternation.rb', line 25

def size
    @elements.size
end

#weightsObject



29
30
31
# File 'lib/jsgf/alternation.rb', line 29

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