class AIXM::W
Weight
@example
AIXM.w(2.9, :t)
Constants
- UNITS
Attributes
unit[R]
@return [Symbol] unit (see {UNITS})
wgt[R]
@return [Float] weight
Public Class Methods
new(wgt, unit)
click to toggle source
# File lib/aixm/w.rb 30 def initialize(wgt, unit) 31 self.wgt, self.unit = wgt, unit 32 end
Public Instance Methods
<=>(other)
click to toggle source
@see Object#<=> @return [Integer]
# File lib/aixm/w.rb 69 def <=>(other) 70 wgt <=> other.send(:"to_#{unit}").wgt 71 end
==(other)
click to toggle source
@see Object#== @return [Boolean]
# File lib/aixm/w.rb 75 def ==(other) 76 self.class === other && (self <=> other).zero? 77 end
Also aliased as: eql?
hash()
click to toggle source
@see Object#hash @return [Integer]
# File lib/aixm/w.rb 82 def hash 83 to_s.hash 84 end
inspect()
click to toggle source
@return [String]
# File lib/aixm/w.rb 35 def inspect 36 %Q(#<#{self.class} #{to_s}>) 37 end
to_s()
click to toggle source
@return [String] human readable representation (e.g. â123 tâ)
# File lib/aixm/w.rb 40 def to_s 41 [wgt, unit].join(' ') 42 end
unit=(value)
click to toggle source
# File lib/aixm/w.rb 49 def unit=(value) 50 fail(ArgumentError, "invalid unit") unless value.respond_to? :to_sym 51 @unit = value.to_sym.downcase 52 fail(ArgumentError, "invalid unit") unless UNITS.has_key? @unit 53 end
wgt=(value)
click to toggle source
# File lib/aixm/w.rb 44 def wgt=(value) 45 fail(ArgumentError, "invalid wgt") unless value.is_a?(Numeric) && value >= 0 46 @wgt = value.to_f 47 end