Class: TenHsServer::Event

Inherits:
Adapter
  • Object
show all
Defined in:
lib/ten_hs_server/event.rb

Overview

Adapter for TenHsServer events endpoint, which returns information for each of the events in Homeseer

Class Method Summary collapse

Class Method Details

.all(deep = false) ⇒ Object

Load all events.

Returns an array of hashes describing each event.



12
13
14
15
16
# File 'lib/ten_hs_server/event.rb', line 12

def self.all deep=false
  response = get "?t=99&f=GetEvents"

  parse_events response.body
end

.find(name) ⇒ Object

Load a single event.

name - An string describing the event

Returns the name of the event



23
24
25
# File 'lib/ten_hs_server/event.rb', line 23

def self.find name
  all.find { |event| event == name }
end

.run(name) ⇒ Object

Run an event.

name - An string describing the event

Returns a bool describing if the event was run or not



32
33
34
35
36
37
# File 'lib/ten_hs_server/event.rb', line 32

def self.run name
  name = URI::encode(name)
  response = get "?t=99&f=RunEvent&d=#{name}"
  
  parse_runevent response.body
end