Class: Arpoon::Controller
- Inherits:
-
EventMachine::Protocols::LineAndTextProtocol
- Object
- EventMachine::Protocols::LineAndTextProtocol
- Arpoon::Controller
show all
- Defined in:
- lib/arpoon/controller.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*args, &block) ⇒ Object
25
26
27
|
# File 'lib/arpoon/controller.rb', line 25
def method_missing (*args, &block)
Arpoon.__send__(*args, &block)
end
|
Instance Method Details
#post_init ⇒ Object
17
18
19
|
# File 'lib/arpoon/controller.rb', line 17
def post_init
connected self
end
|
#receive_line(line) ⇒ Object
21
22
23
|
# File 'lib/arpoon/controller.rb', line 21
def receive_line (line)
command(self, *JSON.parse(line))
end
|
#send_line(line) ⇒ Object
29
30
31
32
33
|
# File 'lib/arpoon/controller.rb', line 29
def send_line (line)
raise ArgumentError, 'the line already has a newline character' if line.include? "\n"
send_data line.dup.force_encoding('BINARY') << "\r\n"
end
|
#send_response(*arguments) ⇒ Object
35
36
37
|
# File 'lib/arpoon/controller.rb', line 35
def send_response (*arguments)
send_line (arguments.length == 1 ? arguments.first : arguments).to_json
end
|
#unbind ⇒ Object
39
40
41
|
# File 'lib/arpoon/controller.rb', line 39
def unbind
disconnected self
end
|