Class: Rain::Matrix

Inherits:
Object
  • Object
show all
Includes:
Observers
Defined in:
lib/matrix/matrix.rb

Instance Method Summary collapse

Constructor Details

#initialize(event_pool:, config: Rain::ConfigLoader.load('./config/matrix.yaml')) ⇒ Matrix

Returns a new instance of Matrix.



16
17
18
19
20
21
22
23
24
25
# File 'lib/matrix/matrix.rb', line 16

def initialize(event_pool:, config: Rain::ConfigLoader.load('./config/matrix.yaml'))
  @event_pool = event_pool
  @config = config

  @screen_size = nil

  @last_stream_index = -1
  @streams = {}
  @columns = []
end

Instance Method Details

#render(screen_size:, show_output: true) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/matrix/matrix.rb', line 27

def render(screen_size:, show_output: true)
  if screen_size != @screen_size
    @screen_size = screen_size
    redraw_streams
  end

  render_streams(show_output:)
end

#update(stream_id:, event_tree:) ⇒ Object



36
37
38
# File 'lib/matrix/matrix.rb', line 36

def update(stream_id:, event_tree:)
  upsert_stream(stream_id:, event_tree:)
end