Class: Terret::Agent
- Inherits:
-
Object
- Object
- Terret::Agent
- Defined in:
- lib/terret/loop.rb
Instance Attribute Summary collapse
-
#ctx ⇒ Object
readonly
Returns the value of attribute ctx.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#session_id ⇒ Object
readonly
Returns the value of attribute session_id.
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
- #drain_inbox ⇒ Object
-
#initialize(id:, session_id:, ctx:) ⇒ Agent
constructor
A new instance of Agent.
- #inject(text) ⇒ Object
Constructor Details
#initialize(id:, session_id:, ctx:) ⇒ Agent
Returns a new instance of Agent.
13 14 15 16 17 18 19 |
# File 'lib/terret/loop.rb', line 13 def initialize(id:, session_id:, ctx:) @id = id @session_id = session_id @ctx = ctx # a forked, agent-scoped context @inbox = [] # injected context waits here until a waking message @status = :idle end |
Instance Attribute Details
#ctx ⇒ Object (readonly)
Returns the value of attribute ctx.
10 11 12 |
# File 'lib/terret/loop.rb', line 10 def ctx @ctx end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
10 11 12 |
# File 'lib/terret/loop.rb', line 10 def id @id end |
#session_id ⇒ Object (readonly)
Returns the value of attribute session_id.
10 11 12 |
# File 'lib/terret/loop.rb', line 10 def session_id @session_id end |
#status ⇒ Object
Returns the value of attribute status.
11 12 13 |
# File 'lib/terret/loop.rb', line 11 def status @status end |
Instance Method Details
#drain_inbox ⇒ Object
25 |
# File 'lib/terret/loop.rb', line 25 def drain_inbox = @inbox.slice!(0..) |
#inject(text) ⇒ Object
21 22 23 |
# File 'lib/terret/loop.rb', line 21 def inject(text) @inbox << text end |