Class: LongMath::CacheKey

Inherits:
Struct
  • Object
show all
Includes:
Comparable
Defined in:
lib/long-decimal.rb,
lib/long-decimal.rb

Overview

used as key to store an already calculated value for any triplet of function name (fname), argument (arg, typically 2, 3, 5, 10 or so) and internal rounding mode (mode)

Instance Method Summary collapse

Instance Method Details

#<=>(o) ⇒ Object

introduce some ordering for cache keys



3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
# File 'lib/long-decimal.rb', line 3098

def <=>(o)
  r = 0
  if o.respond_to?:fname
    r = self.fname <=> o.fname
  else
    r = self.fname <=> o
  end
  return r if (r != 0)
  if o.respond_to?:arg
    r = self.arg <=> o.arg
  else
    r = self.arg <=> o
  end
  return r if (r != 0)
  if o.respond_to?:mode
    r = self.mode <=> o.mode
  else
    r = self.mode <=> o
  end
  return r
end