Class: Quixote
- Inherits:
-
Object
- Object
- Quixote
- Defined in:
- lib/quixote.rb,
lib/quixote/version.rb
Constant Summary collapse
- VERSION =
"0.0.1"
Instance Attribute Summary collapse
-
#last ⇒ Object
Returns the value of attribute last.
-
#max ⇒ Object
Returns the value of attribute max.
-
#min ⇒ Object
Returns the value of attribute min.
-
#range_by ⇒ Object
Returns the value of attribute range_by.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Quixote
constructor
A new instance of Quixote.
- #next ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Quixote
Returns a new instance of Quixote.
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/quixote.rb', line 9 def initialize(={}) defaults = { :max => 100, :min => 0, :range_by => 10 } defaults.merge().each do |key, value| send("#{key}=", value) end @last = random_start_point end |
Instance Attribute Details
#last ⇒ Object
Returns the value of attribute last.
7 8 9 |
# File 'lib/quixote.rb', line 7 def last @last end |
#max ⇒ Object
Returns the value of attribute max.
7 8 9 |
# File 'lib/quixote.rb', line 7 def max @max end |
#min ⇒ Object
Returns the value of attribute min.
7 8 9 |
# File 'lib/quixote.rb', line 7 def min @min end |
#range_by ⇒ Object
Returns the value of attribute range_by.
7 8 9 |
# File 'lib/quixote.rb', line 7 def range_by @range_by end |
Instance Method Details
#next ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/quixote.rb', line 23 def next if last == max decrement elsif last == min || (rand < 0.5) increment else decrement end last end |