Class: VisionMate::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/vision_mate/connection.rb

Overview

Connection is an abstract interface used to wrap the Telnet connection to the scanner. It provides a high level API for the scanner and standardizes the output returned.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, port, telnet_class = Telnet) ⇒ Connection

Returns a new instance of Connection.



9
10
11
# File 'lib/vision_mate/connection.rb', line 9

def initialize(host, port, telnet_class = Telnet)
  self.telnet_connection = Telnet.connect(host, port)
end

Instance Attribute Details

#telnet_connectionObject

Returns the value of attribute telnet_connection.



7
8
9
# File 'lib/vision_mate/connection.rb', line 7

def telnet_connection
  @telnet_connection
end

Instance Method Details

#closeObject



17
18
19
# File 'lib/vision_mate/connection.rb', line 17

def close
  telnet_connection.close
end

#scanObject



13
14
15
# File 'lib/vision_mate/connection.rb', line 13

def scan
  VisionMate::Rack.new(telnet_connection.scan)
end