Class: Gt06Server::Session
- Inherits:
-
Object
- Object
- Gt06Server::Session
- Defined in:
- lib/gt06_server/session.rb
Defined Under Namespace
Classes: SessionError
Instance Attribute Summary collapse
-
#addr ⇒ Object
readonly
Returns the value of attribute addr.
-
#info ⇒ Object
readonly
Returns the value of attribute info.
-
#io ⇒ Object
readonly
Returns the value of attribute io.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#terminal_id ⇒ Object
readonly
Returns the value of attribute terminal_id.
Instance Method Summary collapse
-
#initialize(io, logger: Logger.new(STDOUT)) ⇒ Session
constructor
A new instance of Session.
- #inspect ⇒ Object
- #run {|Hash| ... } ⇒ Object
Constructor Details
#initialize(io, logger: Logger.new(STDOUT)) ⇒ Session
Returns a new instance of Session.
8 9 10 11 12 13 14 15 16 |
# File 'lib/gt06_server/session.rb', line 8 def initialize(io, logger: Logger.new(STDOUT)) @io = io @addr = io.peeraddr @terminal_id = '' @info = { received_count: 0, sent_count: 0, last_received_at: Time.now} @logger = logger logger.debug 'New session has been created' end |
Instance Attribute Details
#addr ⇒ Object (readonly)
Returns the value of attribute addr.
6 7 8 |
# File 'lib/gt06_server/session.rb', line 6 def addr @addr end |
#info ⇒ Object (readonly)
Returns the value of attribute info.
6 7 8 |
# File 'lib/gt06_server/session.rb', line 6 def info @info end |
#io ⇒ Object (readonly)
Returns the value of attribute io.
6 7 8 |
# File 'lib/gt06_server/session.rb', line 6 def io @io end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
6 7 8 |
# File 'lib/gt06_server/session.rb', line 6 def logger @logger end |
#terminal_id ⇒ Object (readonly)
Returns the value of attribute terminal_id.
6 7 8 |
# File 'lib/gt06_server/session.rb', line 6 def terminal_id @terminal_id end |
Instance Method Details
#inspect ⇒ Object
28 29 30 |
# File 'lib/gt06_server/session.rb', line 28 def inspect "#{object_id} Terminal id:#{@terminal_id}, ip: #{@addr}, #{@info}" end |