Class: Xi::TidalClock

Inherits:
Clock show all
Defined in:
lib/xi/tidal_clock.rb

Constant Summary collapse

SYNC_INTERVAL_SEC =
100 / 1000.0

Constants inherited from Clock

Clock::DEFAULT_CPS, Clock::INTERVAL_SEC

Instance Attribute Summary collapse

Attributes inherited from Clock

#init_ts, #latency

Instance Method Summary collapse

Methods inherited from Clock

#bpm, #bpm=, #bps, #bps=, #cps, #current_cycle, #current_time, #inspect, #play, #playing?, #seconds_per_cycle, #stop, #stopped?, #subscribe, #unsubscribe

Constructor Details

#initialize(server: 'localhost', port: 9160, **opts) ⇒ TidalClock

Returns a new instance of TidalClock.



11
12
13
14
15
16
17
18
19
# File 'lib/xi/tidal_clock.rb', line 11

def initialize(server: 'localhost', port: 9160, **opts)
  @server = server
  @port = port
  @attached = true

  super(opts)

  @ws_thread = Thread.new { ws_thread_routine }
end

Instance Attribute Details

#attachedObject (readonly) Also known as: attached?

Returns the value of attribute attached.



8
9
10
# File 'lib/xi/tidal_clock.rb', line 8

def attached
  @attached
end

#portObject (readonly)

Returns the value of attribute port.



8
9
10
# File 'lib/xi/tidal_clock.rb', line 8

def port
  @port
end

#serverObject (readonly)

Returns the value of attribute server.



8
9
10
# File 'lib/xi/tidal_clock.rb', line 8

def server
  @server
end

Instance Method Details

#attachObject



30
31
32
33
# File 'lib/xi/tidal_clock.rb', line 30

def attach
  @attached = true
  self
end

#cps=(new_cps) ⇒ Object



21
22
23
# File 'lib/xi/tidal_clock.rb', line 21

def cps=(new_cps)
  fail NotImplementedError, 'cps is read-only'
end

#dettachObject



25
26
27
28
# File 'lib/xi/tidal_clock.rb', line 25

def dettach
  @attached = false
  self
end