Class: SetPartition::Generator
- Inherits:
-
Object
- Object
- SetPartition::Generator
- Defined in:
- lib/set_partition/generator.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#current ⇒ Object
readonly
Returns the value of attribute current.
Instance Method Summary collapse
- #end ⇒ Object
-
#initialize(length) ⇒ Generator
constructor
A new instance of Generator.
- #length ⇒ Object
- #next ⇒ Object
- #prev ⇒ Object (also: #previous)
- #start ⇒ Object (also: #rewind)
Constructor Details
#initialize(length) ⇒ Generator
Returns a new instance of Generator.
5 6 7 8 9 10 |
# File 'lib/set_partition/generator.rb', line 5 def initialize length @length = length initialize_first initialize_last start end |
Instance Attribute Details
#current ⇒ Object (readonly)
Returns the value of attribute current.
3 4 5 |
# File 'lib/set_partition/generator.rb', line 3 def current @current end |
Instance Method Details
#end ⇒ Object
18 19 20 21 |
# File 'lib/set_partition/generator.rb', line 18 def end @current = @last.dup @maximum = @last.dup end |
#length ⇒ Object
36 37 38 |
# File 'lib/set_partition/generator.rb', line 36 def length partition_length end |
#next ⇒ Object
23 24 25 26 27 |
# File 'lib/set_partition/generator.rb', line 23 def next return if @current == @last next_partition @current end |
#prev ⇒ Object Also known as: previous
29 30 31 32 33 |
# File 'lib/set_partition/generator.rb', line 29 def prev return if @current == @first previous_partition @current end |
#start ⇒ Object Also known as: rewind
12 13 14 15 |
# File 'lib/set_partition/generator.rb', line 12 def start @current = @first.dup @maximum = @first.dup end |