Class: Ncurses::FFIWINDOW

Inherits:
Object show all
Defined in:
lib/ver/ncurses.rb

Overview

This is a window pointer wrapper, to be used for stdscr and others. Ideally ffi-ncurses should do this, if it returns a pointer, I'll do this.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (FFIWINDOW) initialize(*args, &block)

Returns a new instance of FFIWINDOW



171
172
173
174
175
176
177
# File 'lib/ver/ncurses.rb', line 171

def initialize(*args, &block)
  if block_given?
    @pointer = args.first
  else
    @pointer = FFI::NCurses.newwin(*args)
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

- (Object) method_missing(name, *args)



178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/ver/ncurses.rb', line 178

def method_missing(name, *args)
  name = name.to_s
  if (name[0,2] == "mv")
    test_name = name.dup
    test_name[2,0] = "w" # insert "w" after"mv"
    if (FFI::NCurses.respond_to?(test_name))
      return FFI::NCurses.send(test_name, @pointer, *args)
    end
  end
  test_name = "w" + name
  if (FFI::NCurses.respond_to?(test_name))
    return FFI::NCurses.send(test_name, @pointer, *args)
  end
  FFI::NCurses.send(name, @pointer, *args)
end

Instance Attribute Details

- (Object) pointer

Returns the value of attribute pointer



170
171
172
# File 'lib/ver/ncurses.rb', line 170

def pointer
  @pointer
end

Instance Method Details

- (Object) del Also known as: delete



200
201
202
# File 'lib/ver/ncurses.rb', line 200

def del
  FFI::NCurses.delwin(@pointer)
end

- (Boolean) respond_to?(name)

Returns:

  • (Boolean)


193
194
195
196
197
198
199
# File 'lib/ver/ncurses.rb', line 193

def respond_to?(name)
  name = name.to_s
  if (name[0,2] == "mv" && FFI::NCurses.respond_to?("mvw" + name[2..-1]))
    return true
  end
  FFI::NCurses.respond_to?("w" + name) || FFI::NCurses.respond_to?(name)
end