Class: HuginnRubyAgent::Agent

Inherits:
Object
  • Object
show all
Defined in:
lib/huginn_ruby_agent/agent.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code:, credentials: {}) ⇒ Agent



10
11
12
13
14
15
16
17
# File 'lib/huginn_ruby_agent/agent.rb', line 10

def initialize(code:, credentials: {})
  @code = code
  @events = []
  @logs = []
  @errors = []
  @credentials = credentials
  @changed_credentials = {}
end

Instance Attribute Details

#changed_credentialsObject (readonly)

Returns the value of attribute changed_credentials.



8
9
10
# File 'lib/huginn_ruby_agent/agent.rb', line 8

def changed_credentials
  @changed_credentials
end

#errorsObject (readonly)

Returns the value of attribute errors.



8
9
10
# File 'lib/huginn_ruby_agent/agent.rb', line 8

def errors
  @errors
end

#eventsObject (readonly)

Returns the value of attribute events.



8
9
10
# File 'lib/huginn_ruby_agent/agent.rb', line 8

def events
  @events
end

#logsObject (readonly)

Returns the value of attribute logs.



8
9
10
# File 'lib/huginn_ruby_agent/agent.rb', line 8

def logs
  @logs
end

Instance Method Details

#checkObject



19
20
21
# File 'lib/huginn_ruby_agent/agent.rb', line 19

def check
  execute ".check"
end

#create_event(payload) ⇒ Object



27
28
29
# File 'lib/huginn_ruby_agent/agent.rb', line 27

def create_event(payload)
  @events << payload
end

#error(message) ⇒ Object



35
36
37
# File 'lib/huginn_ruby_agent/agent.rb', line 35

def error(message)
  @errors << message
end

#log(message) ⇒ Object



31
32
33
# File 'lib/huginn_ruby_agent/agent.rb', line 31

def log(message)
  @logs << message
end

#receive(events) ⇒ Object



23
24
25
# File 'lib/huginn_ruby_agent/agent.rb', line 23

def receive(events)
  execute ".receive(api.deserialize('#{sdk.serialize(events)}'))"
end

#sdkObject



39
40
41
# File 'lib/huginn_ruby_agent/agent.rb', line 39

def sdk
  @sdk ||= SDK.new
end