Class: Thing

Inherits:
Object
  • Object
show all
Defined in:
lib/thing.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(webService, name, productType = '', displayName = '') ⇒ Thing

Constructor method for Thing.

Parameters:

  • webService (WebService)

    A web service used to communicate with Thingdom.

  • name (String)

    The name of the Thing.

  • productType (String) (defaults to: '')

    The product type the Thing belongs to.

  • displayName (String) (defaults to: '')

    A user friendly name for Thing.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/thing.rb', line 22

def initialize( webService, name, productType = '', displayName = '' )
  @web = webService
  @id = ''
  @name = name
  @product_type = productType
  @display_name = displayName
  @code = ''
  #

  # Perform task to get thing.

  #

  thingTask = ThingTask.new( @web, self )
  response = thingTask.perform()
  #

  # If successful, then update the thing id and code.

  #

  if( response[:response] == 'success' )
    @id = response[:thing_id]
    @code = response[:code]
  end
end

Instance Attribute Details

#codeObject

Public Properties.



12
13
14
# File 'lib/thing.rb', line 12

def code
  @code
end

#display_nameObject

Public Properties.



12
13
14
# File 'lib/thing.rb', line 12

def display_name
  @display_name
end

#idObject

Public Properties.



12
13
14
# File 'lib/thing.rb', line 12

def id
  @id
end

#last_errorObject

Public Properties.



12
13
14
# File 'lib/thing.rb', line 12

def last_error
  @last_error
end

#nameObject

Public Properties.



12
13
14
# File 'lib/thing.rb', line 12

def name
  @name
end

#product_typeObject

Public Properties.



12
13
14
# File 'lib/thing.rb', line 12

def product_type
  @product_type
end

Instance Method Details

#feed(category, message, feedOptions = nil) ⇒ Object

Send a feed with additional feed options.

Parameters:

  • category (String)

    A feed category that was defined during application registration.

  • message (String)

    The feed message.

  • feedOptions (FeedOption) (defaults to: nil)

    Additional feed options: icon, progress bar, etc.



50
51
52
53
# File 'lib/thing.rb', line 50

def feed( category, message, feedOptions = nil )
  feedTask = FeedTask.new( @web, self, category, message, feedOptions )
  feedTask.perform()
end

#status(*args) ⇒ Object

Add or update a status item for this Thing.

Parameters:

  • name (String)

    The status item name.

  • value (String)

    The status item value.

  • unit (String)

    The status item unit.



62
63
64
65
# File 'lib/thing.rb', line 62

def status( *args )
  statusTask = StatusTask.new( @web, self, *args )
  statusTask.perform()
end