Class: Oceanarium::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/oceanarium/resources/event.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(option, api_key, client_id) ⇒ Event

Returns a new instance of Event.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/oceanarium/resources/event.rb', line 5

def initialize(option, api_key, client_id)
  if api_key.nil? || client_id.nil?
    raise 'No API key/client ID!'
  else
    if option.is_a?(Hash)
      @object = option
    else
      @object = Oceanarium::Event.find(option)
    end
    if @object.nil?
      self.id = nil
    else
      self.id = @object['id']
      self.action_status = @object['action_status']
      self.droplet_id = @object['droplet_id']
      self.event_type_id = @object['event_type_id']
      self.percentage = @object['percentage']
    end
  end
end

Instance Attribute Details

#action_statusObject

Returns the value of attribute action_status.



3
4
5
# File 'lib/oceanarium/resources/event.rb', line 3

def action_status
  @action_status
end

#droplet_idObject

Returns the value of attribute droplet_id.



3
4
5
# File 'lib/oceanarium/resources/event.rb', line 3

def droplet_id
  @droplet_id
end

#event_type_idObject

Returns the value of attribute event_type_id.



3
4
5
# File 'lib/oceanarium/resources/event.rb', line 3

def event_type_id
  @event_type_id
end

#idObject

Returns the value of attribute id.



3
4
5
# File 'lib/oceanarium/resources/event.rb', line 3

def id
  @id
end

#percentageObject

Returns the value of attribute percentage.



3
4
5
# File 'lib/oceanarium/resources/event.rb', line 3

def percentage
  @percentage
end

Class Method Details

.find(id) ⇒ Object

Core API



28
29
30
31
32
33
34
# File 'lib/oceanarium/resources/event.rb', line 28

def self.find(id)
  @request = Oceanarium::Request.new
  @get = @request.get("/events/#{id}/")
  if @get.parsed_response['status'] == 'OK'
    @get.parsed_response['event']
  end
end