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(message_interpreter, id) ⇒ Stub

Returns a new instance of Stub.



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

def initialize(message_interpreter, id)
  @message_interpreter = message_interpreter
  @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 @message_interpreter.invoke_api(@id, method, args)
end

Instance Method Details

#==(other) ⇒ Object



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

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

#on(event, &callback) ⇒ Object



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

def on(event, &callback)
  @message_interpreter.register_event_handler(@id, event, callback)
end