Class: NotepadqqApi::Stubs::Stub

Inherits:
Object
  • Object
show all
Defined in:
lib/notepadqq_api/stubs.rb

Direct Known Subclasses

Editor, MenuItem, Notepadqq, Window

Instance Method Summary collapse

Constructor Details

#initialize(messageInterpreter, id) ⇒ Stub

Returns a new instance of Stub.



6
7
8
9
# File 'lib/notepadqq_api/stubs.rb', line 6

def initialize(messageInterpreter, id)
  @messageInterpreter = messageInterpreter
  @id = id
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



15
16
17
# File 'lib/notepadqq_api/stubs.rb', line 15

def method_missing(method, *args, &block)  
  return @messageInterpreter.invokeApi(@id, method, args)
end

Instance Method Details

#==(other) ⇒ Object



19
20
21
# File 'lib/notepadqq_api/stubs.rb', line 19

def ==(other)
  other.class <= Stub && id == other.id
end

#on(event, &callback) ⇒ Object



11
12
13
# File 'lib/notepadqq_api/stubs.rb', line 11

def on(event, &callback)
  @messageInterpreter.registerEventHandler(@id, event, callback)
end