Module: XRBP::NodeStore::STAmount::Comparison

Included in:
XRBP::NodeStore::STAmount
Defined in:
lib/xrbp/nodestore/sle/st_amount_comparison.rb

Instance Method Summary collapse

Instance Method Details

#<(o) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/xrbp/nodestore/sle/st_amount_comparison.rb', line 5

def <(o)
  return self < STAmount.new(:mantissa => o) if o.kind_of?(Numeric)

  return neg if neg && !o.neg
  if mantissa == 0
    return false if o.neg
    return o.mantissa != 0
  end

  return false if o.mantissa == 0
  return  neg  if exponent > o.exponent
  return !neg  if exponent < o.exponent
  return  neg  if mantissa > o.mantissa
  return !neg  if mantissa < o.mantissa

  return false
end

#<=>(o) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/xrbp/nodestore/sle/st_amount_comparison.rb', line 39

def <=>(o)
  return self <=> STAmount.new(:mantissa => o) if o.kind_of?(Numeric)

  return  0 if self == o
  return -1 if self  < o
  return  1 if self  > o
end

#==(o) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/xrbp/nodestore/sle/st_amount_comparison.rb', line 31

def ==(o)
  return self == STAmount.new(:mantissa => o) if o.kind_of?(Numeric)

       neg == o.neg      &&
  mantissa == o.mantissa &&
  exponent == o.exponent
end

#>(o) ⇒ Object



27
28
29
# File 'lib/xrbp/nodestore/sle/st_amount_comparison.rb', line 27

def >(o)
  self >= o && self != o
end

#>=(o) ⇒ Object



23
24
25
# File 'lib/xrbp/nodestore/sle/st_amount_comparison.rb', line 23

def >=(o)
  !(self < o)
end