Class: RETerm::Components::Matrix

Inherits:
RETerm::Component show all
Includes:
RETerm::CDKComponent
Defined in:
lib/reterm/components/matrix.rb

Overview

CDK Matrix Component

Constant Summary

Constants included from LogHelpers

LogHelpers::LOG_FILE

Instance Attribute Summary

Attributes inherited from RETerm::Component

#activatable, #activate_focus, #highlight_focus, #window

Instance Method Summary collapse

Methods included from RETerm::CDKComponent

#activatable?, #activate!, #bind_key, #cdk?, #colors=, #component, #deactivate!, #draw!, #early_exit?, #erase, #escape_hit?, #init?, #init_cdk, #normal_exit?, #strip_formatting, #title_attrib=, #value

Methods inherited from RETerm::Component

#activatable?, #activate!, #activate_focus?, #cdk?, #colored?, #colors=, #deactivate!, #deactivate?, #distance_from, #extra_padding, #finalize!, #highlight_focus?, #reactivate!, #requested_rows, #resize, #sync!, #sync_getch

Methods included from KeyBindings

#bind_key, #invoke_key_bindings, #key_bindings, #key_bound?

Methods included from LogHelpers

#logger

Methods included from EventDispatcher

#dispatch, #handle

Constructor Details

#initialize(args = {}) ⇒ Matrix

Initialize the Matrix component

Parameters:

  • args (Hash) (defaults to: {})

    matrix params



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/reterm/components/matrix.rb', line 10

def initialize(args={})
  super
  @rows  = args[:rows]
  @cols  = args[:cols]
  @title = args[:title]

  @rowtitles = args[:rowtitles] || args[:row_titles] || Array.new(@rows) { "" }
  @coltitles = args[:coltitles] || args[:col_titles] || Array.new(@cols+1) { "" }
  @colwidths = args[:colwidths] || args[:col_widths] || Array.new(@cols+1) { 5 }
  @coltypes  = args[:coltypes]  || args[:col_types]  || Array.new(@cols+1) { :UMIXED }
end

Instance Method Details

#get(x, y) ⇒ Object



22
23
24
# File 'lib/reterm/components/matrix.rb', line 22

def get(x, y)
  component.getCell(x, y)
end

#requeseted_rowsObject



26
27
28
# File 'lib/reterm/components/matrix.rb', line 26

def requeseted_rows
  4 + 2 * rows + 1
end

#requested_colsObject



30
31
32
# File 'lib/reterm/components/matrix.rb', line 30

def requested_cols
  2 + 2 * rows + 1
end