Class: Arcenciel::Chaser

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

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

#deviceObject (readonly)

Returns the value of attribute device.



11
12
13
# File 'lib/arcenciel/utility/chaser.rb', line 11

def device
  @device
end

#indexObject (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

.advanceObject



18
19
20
21
22
# File 'lib/arcenciel/utility/chaser.rb', line 18

def self.advance
  @position ||= 0
  @position += 1
  @position %= 64
end

.positionObject



14
15
16
# File 'lib/arcenciel/utility/chaser.rb', line 14

def self.position
  @position ||= 0
end

Instance Method Details

#running?Boolean

Returns:

  • (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