Class: MacTypes::Units

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, type) ⇒ Units

Returns a new instance of Units.



216
217
218
219
# File 'lib/_aem/mactypes.rb', line 216

def initialize(value, type)
  @value = value
  @type = type
end

Instance Attribute Details

#typeObject (readonly)

Represents a measurement; e.g. 3 inches, 98.5 degrees Fahrenheit.

The AEM defines a standard set of unit types; some applications may define additional types for their own use. This wrapper stores the raw unit type and value data; aem/appscript Codecs objects will convert this to/from an AEDesc, or raise an error if the unit type is unrecognised.



214
215
216
# File 'lib/_aem/mactypes.rb', line 214

def type
  @type
end

#valueObject (readonly)

Represents a measurement; e.g. 3 inches, 98.5 degrees Fahrenheit.

The AEM defines a standard set of unit types; some applications may define additional types for their own use. This wrapper stores the raw unit type and value data; aem/appscript Codecs objects will convert this to/from an AEDesc, or raise an error if the unit type is unrecognised.



214
215
216
# File 'lib/_aem/mactypes.rb', line 214

def value
  @value
end

Instance Method Details

#==(val) ⇒ Object Also known as: eql?



221
222
223
224
225
# File 'lib/_aem/mactypes.rb', line 221

def ==(val)
  return (self.equal?(val) or (
                               self.class == val.class and
                                 @value == val.value and @type == val.type))
end

#hashObject



229
230
231
# File 'lib/_aem/mactypes.rb', line 229

def hash
  return [@value, @type].hash
end

#inspectObject



245
246
247
# File 'lib/_aem/mactypes.rb', line 245

def inspect
  return "MacTypes::Units.new(#{@value.inspect}, #{@type.inspect})"
end

#to_fObject



237
238
239
# File 'lib/_aem/mactypes.rb', line 237

def to_f
  return @value.to_f
end

#to_iObject



233
234
235
# File 'lib/_aem/mactypes.rb', line 233

def to_i
  return @value.to_i
end

#to_sObject



241
242
243
# File 'lib/_aem/mactypes.rb', line 241

def to_s
  return "#{@value.inspect} #{@type.tr('_', ' ')}"
end