class AIXM::P

pressure

@example

AIXM.d(14, :bar)

Constants

UNITS

Attributes

pres[R]

@return [Float] pressure

unit[R]

@return [Symbol] unit (see {UNITS})

Public Class Methods

new(pres, unit) click to toggle source
   # File lib/aixm/p.rb
31 def initialize(pres, unit)
32   self.pres, self.unit = pres, unit
33 end

Public Instance Methods

<=>(other) click to toggle source

@see Object#<=> @return [Integer]

   # File lib/aixm/p.rb
71 def <=>(other)
72   pres <=> other.send(:"to_#{unit}").pres
73 end
==(other) click to toggle source

@see Object#== @return [Boolean]

   # File lib/aixm/p.rb
77 def ==(other)
78   self.class === other  && (self <=> other).zero?
79 end
Also aliased as: eql?
eql?(other)
Alias for: ==
hash() click to toggle source

@see Object#hash @return [Integer]

   # File lib/aixm/p.rb
84 def hash
85   to_s.hash
86 end
inspect() click to toggle source

@return [String]

   # File lib/aixm/p.rb
36 def inspect
37   %Q(#<#{self.class} #{to_s}>)
38 end
pres=(value) click to toggle source
   # File lib/aixm/p.rb
45 def pres=(value)
46   fail(ArgumentError, "invalid pres") unless value.is_a?(Numeric) && value >= 0
47   @pres = value.to_f
48 end
to_s() click to toggle source

@return [String] human readable representation (e.g. “14 bar”)

   # File lib/aixm/p.rb
41 def to_s
42   [pres, unit].join(' ')
43 end
unit=(value) click to toggle source
   # File lib/aixm/p.rb
50 def unit=(value)
51   fail(ArgumentError, "invalid unit") unless value.respond_to? :to_sym
52   @unit = value.to_sym.downcase
53   fail(ArgumentError, "invalid unit") unless UNITS.has_key? @unit
54 end