Class: Dawn::Gear
Instance Attribute Summary collapse
- #app ⇒ Object
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Class Method Summary collapse
Instance Method Summary collapse
- #app_id ⇒ Object
- #destroy(options = {}) ⇒ Object
- #id ⇒ Object
-
#initialize(data) ⇒ Gear
constructor
A new instance of Gear.
- #name ⇒ Object
- #number ⇒ Object
- #refresh ⇒ Object
- #restart(options = {}) ⇒ Object
- #type ⇒ Object
- #update(options = {}) ⇒ Object
- #uptime ⇒ Object
Methods included from BaseApi
Methods included from BaseApi::Extension
Constructor Details
#initialize(data) ⇒ Gear
Returns a new instance of Gear.
11 12 13 14 |
# File 'lib/dawn/api/gear.rb', line 11 def initialize(data) @app = nil @data = data end |
Instance Attribute Details
#app ⇒ Object
20 21 22 |
# File 'lib/dawn/api/gear.rb', line 20 def app @app ||= App.find(id: app_id) end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
8 9 10 |
# File 'lib/dawn/api/gear.rb', line 8 def data @data end |
Class Method Details
.all(options = {}) ⇒ Object
80 81 82 83 84 85 86 87 |
# File 'lib/dawn/api/gear.rb', line 80 def self.all(={}) json_request( expects: 200, method: :get, path: "/gears", query: ).map { |hsh| new hsh["gear"] } end |
.find(options) ⇒ Object
89 90 91 92 93 94 95 96 97 98 |
# File 'lib/dawn/api/gear.rb', line 89 def self.find() id = .delete(:id) new json_request( expects: 200, method: :get, path: "/gears/#{id}", query: )["gear"] end |
Instance Method Details
#app_id ⇒ Object
16 17 18 |
# File 'lib/dawn/api/gear.rb', line 16 def app_id data["app_id"] end |
#destroy(options = {}) ⇒ Object
71 72 73 74 75 76 77 78 |
# File 'lib/dawn/api/gear.rb', line 71 def destroy(={}) request( expects: 200, method: :delete, path: "/gears/#{id}", query: ) end |
#id ⇒ Object
24 25 26 |
# File 'lib/dawn/api/gear.rb', line 24 def id data["id"] end |
#name ⇒ Object
28 29 30 |
# File 'lib/dawn/api/gear.rb', line 28 def name data["name"] end |
#number ⇒ Object
40 41 42 |
# File 'lib/dawn/api/gear.rb', line 40 def number data["number"] end |
#refresh ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/dawn/api/gear.rb', line 44 def refresh @data = json_request( expects: 200, method: :get, path: "/gears/#{id}", query: )["gear"] end |
#restart(options = {}) ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'lib/dawn/api/gear.rb', line 53 def restart(={}) request( expects: 200, method: :post, path: "/gears/#{id}/restart", query: ) end |
#type ⇒ Object
36 37 38 |
# File 'lib/dawn/api/gear.rb', line 36 def type data["type"] end |
#update(options = {}) ⇒ Object
62 63 64 65 66 67 68 69 |
# File 'lib/dawn/api/gear.rb', line 62 def update(={}) request( expects: 200, method: :post, path: "/gears/#{id}", body: .to_json ) end |
#uptime ⇒ Object
32 33 34 |
# File 'lib/dawn/api/gear.rb', line 32 def uptime data["uptime"] end |