Class: RubyNos::RemoteAgent

Inherits:
Object
  • Object
show all
Includes:
Initializable
Defined in:
lib/ruby_nos/remote_agent.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Initializable

#initialize

Instance Attribute Details

#endpointsObject

Returns the value of attribute endpoints.



4
5
6
# File 'lib/ruby_nos/remote_agent.rb', line 4

def endpoints
  @endpoints
end

#rest_apiObject

Returns the value of attribute rest_api.



4
5
6
# File 'lib/ruby_nos/remote_agent.rb', line 4

def rest_api
  @rest_api
end

#timestampObject

Returns the value of attribute timestamp.



4
5
6
# File 'lib/ruby_nos/remote_agent.rb', line 4

def timestamp
  @timestamp
end

#uuidObject

Returns the value of attribute uuid.



4
5
6
# File 'lib/ruby_nos/remote_agent.rb', line 4

def uuid
  @uuid
end

Instance Method Details

#add_endpoint(*args) ⇒ Object



10
11
12
# File 'lib/ruby_nos/remote_agent.rb', line 10

def add_endpoint *args
  endpoints << Endpoint.new(*args)
end

#endpoints_collectionObject



14
15
16
# File 'lib/ruby_nos/remote_agent.rb', line 14

def endpoints_collection
  endpoints.map{|e| e.to_hash}
end

#same_api?(another_agent) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
25
26
27
28
# File 'lib/ruby_nos/remote_agent.rb', line 22

def same_api? another_agent
  if rest_api && another_agent.rest_api
    rest_api.to_hash == another_agent.rest_api.to_hash
  else
    false
  end
end

#same_endpoints?(another_agent) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/ruby_nos/remote_agent.rb', line 18

def same_endpoints? another_agent
  endpoints_collection == another_agent.endpoints_collection
end

#same_timestamp?(another_agent) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/ruby_nos/remote_agent.rb', line 30

def same_timestamp? another_agent
  timestamp == another_agent.timestamp
end

#to_hashObject



34
35
36
37
38
39
# File 'lib/ruby_nos/remote_agent.rb', line 34

def to_hash
  {
      uuid: uuid,
      timestamp: Time.at(timestamp/1000)
  }
end