Class: Ncurses::WINDOW
- Inherits:
-
Object
- Object
- Ncurses::WINDOW
- Defined in:
- lib/ffi-ncurses/ncurses.rb
Instance Attribute Summary collapse
-
#win ⇒ Object
Returns the value of attribute win.
Instance Method Summary collapse
- #del ⇒ Object (also: #delete)
-
#initialize(*args, &block) ⇒ WINDOW
constructor
A new instance of WINDOW.
-
#method_missing(name, *args) ⇒ Object
Lifted from Ncurses.
- #respond_to?(name) ⇒ Boolean
Constructor Details
#initialize(*args, &block) ⇒ WINDOW
Returns a new instance of WINDOW.
68 69 70 71 72 73 74 75 76 77 |
# File 'lib/ffi-ncurses/ncurses.rb', line 68 def initialize(*args, &block) # SOH: Lifted from Ncurses. One example of how truly horrible # that interface is (using the existence of an otherwise useless # block as a flag). if block_given? @win = args.first else @win = FFI::NCurses.newwin(*args) end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
Lifted from Ncurses.
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/ffi-ncurses/ncurses.rb', line 80 def method_missing(name, *args) # log(:mm, 1, name) name = name.to_s if name[0,2] == "mv" # log(:mm, 2, "mv") test_name = name.dup test_name[2,0] = "w" # insert "w" after"mv" if FFI::NCurses.respond_to?(test_name) # log(:mm, 2.1, test_name) Ncurses.send(test_name, @win, *args) else super end else # log(:mm, 3, "w") test_name = "w" + name if FFI::NCurses.respond_to?(test_name) # log(:mm, 4, test_name) Ncurses.send(test_name, @win, *args) elsif FFI::NCurses.respond_to?(name) # log(:mm, 5, name) Ncurses.send(name, @win, *args) else super end end end |
Instance Attribute Details
#win ⇒ Object
Returns the value of attribute win.
66 67 68 |
# File 'lib/ffi-ncurses/ncurses.rb', line 66 def win @win end |
Instance Method Details
#del ⇒ Object Also known as: delete
121 122 123 |
# File 'lib/ffi-ncurses/ncurses.rb', line 121 def del FFI::NCurses.delwin(@win) end |
#respond_to?(name) ⇒ Boolean
108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/ffi-ncurses/ncurses.rb', line 108 def respond_to?(name) if super true else name = name.to_s if name[0,2] == "mv" && FFI::NCurses.respond_to?("mvw" + name[2..-1]) true else FFI::NCurses.respond_to?("w" + name) || FFI::NCurses.respond_to?(name) end end end |