Class: Srgs::Item

Inherits:
Object
  • Object
show all
Defined in:
lib/srgs/elements/item.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(element = '', repeat = nil, repeat_prob = nil, weight = nil) ⇒ Item

Returns a new instance of Item.



6
7
8
9
10
11
12
# File 'lib/srgs/elements/item.rb', line 6

def initialize(element = '', repeat=nil, repeat_prob = nil, weight = nil)
  @elements = []
  @elements << element unless element == ''
  @repeat = repeat
  @repeat_prob = repeat_prob
  @weight = weight
end

Instance Attribute Details

#elementsObject

Returns the value of attribute elements.



4
5
6
# File 'lib/srgs/elements/item.rb', line 4

def elements
  @elements
end

#repeatObject

Returns the value of attribute repeat.



4
5
6
# File 'lib/srgs/elements/item.rb', line 4

def repeat
  @repeat
end

#repeat_probObject

Returns the value of attribute repeat_prob.



4
5
6
# File 'lib/srgs/elements/item.rb', line 4

def repeat_prob
  @repeat_prob
end

#weightObject

Returns the value of attribute weight.



4
5
6
# File 'lib/srgs/elements/item.rb', line 4

def weight
  @weight
end

Instance Method Details

#<<(element) ⇒ Object



14
15
16
17
# File 'lib/srgs/elements/item.rb', line 14

def <<(element)
  @elements << element
  self
end