class Mobi::Mtld::Da::Properties

Copyright
Author

Contains a hash of names to Property objects. An instance of this class is returned by DeviceApi.properties.

Public Instance Methods

[](property_name) click to toggle source

Overload of [](key) to consider property names as strings or symbols.

property_name

String or Symbol with the property_name.

return

Property value or nil if the property does not exist.

Calls superclass method
# File ../../device_api/trunk/ruby/src/lib/properties.rb, line 48
def [](property_name)
  if property_name.nil?
    return nil
  end
  return super(property_name) || super(property_name.to_sym)
end
contains?(property_name, value_to_check = nil) click to toggle source

Checks whether the properties set has the given pair of property and value.

property_name

String or Symbol with the property name.

value_to_check

Value to check.

return

Boolean value.

# File ../../device_api/trunk/ruby/src/lib/properties.rb, line 25
def contains?(property_name, value_to_check = nil)
  if property_name.nil?
    return
  end
  if self.has_key?(property_name) && !value_to_check.nil?
    property = self[property_name]
    if property.data_type_id == DataType::BOOLEAN
      case value_to_check
      when 0,"0",false
          value_to_check = false
      when 1,"1",true
          value_to_check = true
      end
      return property.to_b == value_to_check
    end
    return property.to_s == value_to_check.to_s
  end
  return false
end
delete(property_name) click to toggle source

Overload delete() to allow property names as symbols.

property_name

String or Symbol with the property_name.

return

Property object or nil if the property does not exist.

Calls superclass method
# File ../../device_api/trunk/ruby/src/lib/properties.rb, line 72
def delete(property_name)
  super(property_name) || super(property_name.to_sym)
end
get(property_name) click to toggle source

Gets the value of the given property identified by its name.

property_name

String or Symbol with the property_name.

return

Property value or nil if the property does not exist.

# File ../../device_api/trunk/ruby/src/lib/properties.rb, line 58
def get property_name
  return self[property_name]
end
has_key?(property_name) click to toggle source

Overload has_key? to allow property names as symbols.

property_name

String or Symbol with the property_name.

return

Whether the property name exists in they key set.

Calls superclass method
# File ../../device_api/trunk/ruby/src/lib/properties.rb, line 65
def has_key?(property_name)
  return super(property_name) || super(property_name.to_sym)
end