Class: Curtis::BaseView
- Inherits:
-
Object
- Object
- Curtis::BaseView
- Extended by:
- Forwardable
- Includes:
- Helpers::Border, Helpers::Text
- Defined in:
- lib/curtis/base_view.rb,
lib/curtis/base_view/size.rb,
lib/curtis/base_view/cursor.rb,
lib/curtis/base_view/position.rb
Direct Known Subclasses
Defined Under Namespace
Classes: Cursor, Position, Size
Instance Attribute Summary collapse
-
#cursor ⇒ Object
readonly
Returns the value of attribute cursor.
-
#position ⇒ Object
readonly
Returns the value of attribute position.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#window ⇒ Object
readonly
Returns the value of attribute window.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(ncurses_window) ⇒ BaseView
constructor
A new instance of BaseView.
- #method_missing(method_name, *arguments, &block) ⇒ Object
- #move_cursor(line: 0, column: 0) ⇒ Object
- #parent ⇒ Object
- #render ⇒ Object
- #respond_to_missing?(method_name, include_private = false) ⇒ Boolean
- #setup ⇒ Object
Methods included from Helpers::Border
Methods included from Helpers::Text
Constructor Details
#initialize(ncurses_window) ⇒ BaseView
Returns a new instance of BaseView.
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/curtis/base_view.rb', line 24 def initialize(ncurses_window) unless ncurses_window.kind_of? Ncurses::WINDOW fail ArgumentError, 'Only Ncurses::WINDOW instances allowed.' end @window = ncurses_window @cursor = Cursor.new(self) @size = Size.new(self) @position = Position.new(self) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *arguments, &block) ⇒ Object
35 36 37 38 |
# File 'lib/curtis/base_view.rb', line 35 def method_missing(method_name, *arguments, &block) return super unless window.respond_to?(method_name) window.send(method_name, *arguments, &block) end |
Instance Attribute Details
#cursor ⇒ Object (readonly)
Returns the value of attribute cursor.
9 10 11 |
# File 'lib/curtis/base_view.rb', line 9 def cursor @cursor end |
#position ⇒ Object (readonly)
Returns the value of attribute position.
9 10 11 |
# File 'lib/curtis/base_view.rb', line 9 def position @position end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
9 10 11 |
# File 'lib/curtis/base_view.rb', line 9 def size @size end |
#window ⇒ Object (readonly)
Returns the value of attribute window.
10 11 12 |
# File 'lib/curtis/base_view.rb', line 10 def window @window end |
Class Method Details
.instance ⇒ Object
19 20 21 |
# File 'lib/curtis/base_view.rb', line 19 def instance @instance ||= self.new(Ncurses.stdscr) end |
Instance Method Details
#move_cursor(line: 0, column: 0) ⇒ Object
56 57 58 |
# File 'lib/curtis/base_view.rb', line 56 def move_cursor(line: 0, column: 0) window.move(line, column) end |
#parent ⇒ Object
47 48 49 50 |
# File 'lib/curtis/base_view.rb', line 47 def parent setup window end |
#render ⇒ Object
52 53 54 |
# File 'lib/curtis/base_view.rb', line 52 def render window.refresh end |
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
40 41 42 |
# File 'lib/curtis/base_view.rb', line 40 def respond_to_missing?(method_name, include_private = false) window.respond_to?(method_name) || super end |
#setup ⇒ Object
44 45 |
# File 'lib/curtis/base_view.rb', line 44 def setup end |