Class: Quixote
- Inherits:
-
Object
- Object
- Quixote
- Defined in:
- lib/quixote.rb,
lib/quixote/version.rb
Constant Summary collapse
- VERSION =
"0.2.0"
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.
-
#progress ⇒ Object
Returns the value of attribute progress.
-
#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 22 23 |
# File 'lib/quixote.rb', line 9 def initialize(={}) start = .delete(:start) defaults = { max: 100, min: 0, range_by: 10 } defaults.merge().each do |key, value| send("#{key}=", value) end @last = start || 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 |
#progress ⇒ Object
Returns the value of attribute progress.
7 8 9 |
# File 'lib/quixote.rb', line 7 def progress @progress 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
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/quixote.rb', line 25 def next if progress run_custom elsif last == max decrement elsif last == min || (rand < 0.5) increment else decrement end last end |