Class: Termplot::Widgets::BaseWidget
- Inherits:
-
Object
- Object
- Termplot::Widgets::BaseWidget
- Includes:
- Renderable
- Defined in:
- lib/termplot/widgets/base_widget.rb
Direct Known Subclasses
Defined Under Namespace
Classes: BorderedWindow
Instance Attribute Summary collapse
-
#bordered_window ⇒ Object
readonly
Returns the value of attribute bordered_window.
-
#cols ⇒ Object
readonly
Returns the value of attribute cols.
-
#dataset ⇒ Object
readonly
Returns the value of attribute dataset.
-
#decimals ⇒ Object
readonly
Returns the value of attribute decimals.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#rows ⇒ Object
readonly
Returns the value of attribute rows.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#window ⇒ Object
readonly
Returns the value of attribute window.
Instance Method Summary collapse
- #<<(point) ⇒ Object
-
#initialize(**opts) ⇒ BaseWidget
constructor
A new instance of BaseWidget.
- #post_initialize(opts) ⇒ Object
- #render_to_window ⇒ Object
Methods included from Renderable
#debug?, #render, #render_to_string
Constructor Details
#initialize(**opts) ⇒ BaseWidget
Returns a new instance of BaseWidget.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/termplot/widgets/base_widget.rb', line 22 def initialize(**opts) @cols = opts[:cols] >= min_cols ? opts[:cols] : min_cols @rows = opts[:rows] >= min_rows ? opts[:rows] : min_rows @window = Window.new( cols: @cols, rows: @rows ) @bordered_window = BorderedWindow.new(window, default_border_size) @debug = opts[:debug] @errors = [] @title = opts[:title] @decimals = 2 @dataset = Dataset.new(max_count) post_initialize(opts) end |
Instance Attribute Details
#bordered_window ⇒ Object (readonly)
Returns the value of attribute bordered_window.
11 12 13 |
# File 'lib/termplot/widgets/base_widget.rb', line 11 def bordered_window @bordered_window end |
#cols ⇒ Object (readonly)
Returns the value of attribute cols.
11 12 13 |
# File 'lib/termplot/widgets/base_widget.rb', line 11 def cols @cols end |
#dataset ⇒ Object (readonly)
Returns the value of attribute dataset.
11 12 13 |
# File 'lib/termplot/widgets/base_widget.rb', line 11 def dataset @dataset end |
#decimals ⇒ Object (readonly)
Returns the value of attribute decimals.
11 12 13 |
# File 'lib/termplot/widgets/base_widget.rb', line 11 def decimals @decimals end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
11 12 13 |
# File 'lib/termplot/widgets/base_widget.rb', line 11 def errors @errors end |
#rows ⇒ Object (readonly)
Returns the value of attribute rows.
11 12 13 |
# File 'lib/termplot/widgets/base_widget.rb', line 11 def rows @rows end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
11 12 13 |
# File 'lib/termplot/widgets/base_widget.rb', line 11 def title @title end |
#window ⇒ Object (readonly)
Returns the value of attribute window.
11 12 13 |
# File 'lib/termplot/widgets/base_widget.rb', line 11 def window @window end |
Instance Method Details
#<<(point) ⇒ Object
46 47 48 49 |
# File 'lib/termplot/widgets/base_widget.rb', line 46 def <<(point) dataset << point dataset.set_capacity(max_count) end |
#post_initialize(opts) ⇒ Object
42 43 44 |
# File 'lib/termplot/widgets/base_widget.rb', line 42 def post_initialize(opts) # Implemented by subclasses end |
#render_to_window ⇒ Object
51 52 53 |
# File 'lib/termplot/widgets/base_widget.rb', line 51 def render_to_window raise "Must be implemented" end |