Class: Baldr::Loop
- Inherits:
-
Object
- Object
- Baldr::Loop
- Defined in:
- lib/baldr/loop.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#segments ⇒ Object
readonly
Returns the value of attribute segments.
Instance Method Summary collapse
- #add(segment) ⇒ Object
- #count ⇒ Object
- #current_segment ⇒ Object
-
#initialize(id) ⇒ Loop
constructor
A new instance of Loop.
- #number_of_segments ⇒ Object
Constructor Details
#initialize(id) ⇒ Loop
Returns a new instance of Loop.
5 6 7 8 |
# File 'lib/baldr/loop.rb', line 5 def initialize(id) @segments = [] @id = id end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/baldr/loop.rb', line 3 def id @id end |
#segments ⇒ Object (readonly)
Returns the value of attribute segments.
3 4 5 |
# File 'lib/baldr/loop.rb', line 3 def segments @segments end |
Instance Method Details
#add(segment) ⇒ Object
10 11 12 |
# File 'lib/baldr/loop.rb', line 10 def add(segment) @segments << segment end |
#count ⇒ Object
14 15 16 |
# File 'lib/baldr/loop.rb', line 14 def count @segments.length end |
#current_segment ⇒ Object
22 23 24 |
# File 'lib/baldr/loop.rb', line 22 def current_segment @segments.last end |
#number_of_segments ⇒ Object
18 19 20 |
# File 'lib/baldr/loop.rb', line 18 def number_of_segments @segments.map(&:number_of_segments).sum end |