Class: Beanie::WorkCentre

Inherits:
Api
  • Object
show all
Defined in:
lib/beanie/work_centre.rb

Constant Summary collapse

STATE_UNKNOWN =
0
STATE_MAINTENANCE =
1
STATE_OFFLINE =
2
STATE_READY =
3
STATE_BUSY =
4
STATE_DONE =
5
STATE_NAMES =
[
  ["Unknown State", STATE_UNKNOWN],
  ["Maintenance Mode", STATE_MAINTENANCE],
  ["Offline (Unavailable)", STATE_OFFLINE],
  ["Ready for Work", STATE_READY],
  ["Working (Busy)", STATE_BUSY],
  ["Work Complete", STATE_DONE]
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Api

all, build_url, delete, #extract, #field_name, find, get, #object_name, #populate, post, put, #save!, set_headers

Constructor Details

#initializeWorkCentre

Initialize instance variables



52
53
54
55
56
57
58
59
# File 'lib/beanie/work_centre.rb', line 52

def initialize
  @id = nil
  @name = nil
  @state = nil
  @location = nil
  @description = nil
  @work_centre_group_id = nil
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



32
33
34
# File 'lib/beanie/work_centre.rb', line 32

def description
  @description
end

#idObject

Returns the value of attribute id.



32
33
34
# File 'lib/beanie/work_centre.rb', line 32

def id
  @id
end

#locationObject

Returns the value of attribute location.



32
33
34
# File 'lib/beanie/work_centre.rb', line 32

def location
  @location
end

#nameObject

Returns the value of attribute name.



32
33
34
# File 'lib/beanie/work_centre.rb', line 32

def name
  @name
end

#stateObject

Returns the value of attribute state.



32
33
34
# File 'lib/beanie/work_centre.rb', line 32

def state
  @state
end

#work_centre_group_idObject

Returns the value of attribute work_centre_group_id.



32
33
34
# File 'lib/beanie/work_centre.rb', line 32

def work_centre_group_id
  @work_centre_group_id
end

Instance Method Details

#construct_path(opts = {}) ⇒ Object

Construct the path a little differently…



83
84
85
86
87
88
89
90
91
# File 'lib/beanie/work_centre.rb', line 83

def construct_path(opts = {})
  if opts[:work_centre_group_id]
    path = "/work_centre_groups/#{opts[:work_centre_group_id]}/work_centres"
    opts.delete(:work_centre_group_id)
  else
    path = "/work_centres"
  end
  path
end

#private_dataObject

Get the private data



69
70
71
72
# File 'lib/beanie/work_centre.rb', line 69

def private_data
  response = WorkCentre.get(:url => "/work_centres/#{@id}/private_data")
  response["data"]
end

#private_data=(data) ⇒ Object

Update/set the private data



76
77
78
79
# File 'lib/beanie/work_centre.rb', line 76

def private_data=(data)
  pdata = {:data => data}
  response = WorkCentre.post(pdata, :url => "/work_centres/#{@id}/private_data")
end

#state_nameObject

State name



63
64
65
# File 'lib/beanie/work_centre.rb', line 63

def state_name
  STATE_NAMES[@state][0]
end