Class: Arcenciel::Chaser
- Inherits:
-
Object
- Object
- Arcenciel::Chaser
- Defined in:
- lib/arcenciel/utility/chaser.rb
Constant Summary collapse
- MAX_LEVEL =
13
- SEQUENCE =
(1..5).to_a.reverse.map do |i| (MAX_LEVEL * 1.0 / (i * i)).to_i end
Instance Attribute Summary collapse
-
#device ⇒ Object
readonly
Returns the value of attribute device.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(device, index) ⇒ Chaser
constructor
A new instance of Chaser.
- #running? ⇒ Boolean
- #start! ⇒ Object
- #stop! ⇒ Object
Constructor Details
#initialize(device, index) ⇒ Chaser
Returns a new instance of Chaser.
24 25 26 27 28 29 30 |
# File 'lib/arcenciel/utility/chaser.rb', line 24 def initialize(device, index) @device = device @index = index @running = false @thread = nil end |
Instance Attribute Details
#device ⇒ Object (readonly)
Returns the value of attribute device.
11 12 13 |
# File 'lib/arcenciel/utility/chaser.rb', line 11 def device @device end |
#index ⇒ Object (readonly)
Returns the value of attribute index.
12 13 14 |
# File 'lib/arcenciel/utility/chaser.rb', line 12 def index @index end |
Class Method Details
.advance ⇒ Object
18 19 20 21 22 |
# File 'lib/arcenciel/utility/chaser.rb', line 18 def self.advance @position ||= 0 @position += 1 @position %= 64 end |
.position ⇒ Object
14 15 16 |
# File 'lib/arcenciel/utility/chaser.rb', line 14 def self.position @position ||= 0 end |
Instance Method Details
#running? ⇒ Boolean
32 33 34 |
# File 'lib/arcenciel/utility/chaser.rb', line 32 def running? !!@running end |
#start! ⇒ Object
36 37 38 39 40 41 |
# File 'lib/arcenciel/utility/chaser.rb', line 36 def start! return if running? @running = true ring_clear run_async end |
#stop! ⇒ Object
43 44 45 46 47 48 |
# File 'lib/arcenciel/utility/chaser.rb', line 43 def stop! return if !running? @running = false join_async ring_clear end |