Class: Rain::Matrix
Instance Method Summary collapse
-
#initialize(event_pool:, config: ConfigLoader.load('./config/matrix.yaml')) ⇒ Matrix
constructor
A new instance of Matrix.
-
#new_event_tree(event: Low::Events::EventTree) ⇒ Object
TODO: Introduce “on :new_event_tree do |event|” block construct in LowEvent for making event handlers more obvious.
- #redraw(screen_size:) ⇒ Object
- #render(screen_size:, show_output: true) ⇒ Object
Constructor Details
#initialize(event_pool:, config: ConfigLoader.load('./config/matrix.yaml')) ⇒ Matrix
Returns a new instance of Matrix.
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/matrix/matrix.rb', line 14 def initialize(event_pool:, config: ConfigLoader.load('./config/matrix.yaml')) @event_pool = event_pool @config = config @screen_size = nil @last_stream_index = -1 @streams = {} # TODO: Could be a "stream pool" like event pool (a pool hash). @columns = [] end |
Instance Method Details
#new_event_tree(event: Low::Events::EventTree) ⇒ Object
TODO: Introduce “on :new_event_tree do |event|” block construct in LowEvent for making event handlers more obvious. TODO: Observers should allow arbitrary params when triggering and observing.
44 45 46 47 |
# File 'lib/matrix/matrix.rb', line 44 def new_event_tree(event: Low::Events::EventTree) stream = upsert_stream(event_tree: event) stream.redraw(cell_count: @screen_size[:row_count]) end |
#redraw(screen_size:) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/matrix/matrix.rb', line 25 def redraw(screen_size:) @setup ||= setup @streams.each_value do |stream| stream.redraw(cell_count: screen_size[:row_count]) end end |
#render(screen_size:, show_output: true) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/matrix/matrix.rb', line 33 def render(screen_size:, show_output: true) if screen_size != @screen_size @screen_size = screen_size redraw(screen_size:) end render_streams(show_output:) end |