Module: NumericValue

Extended by:
Entity
Defined in:
lib/rbbt/rest/common/table.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.tsv_sort(v) ⇒ Object



121
122
123
124
125
126
127
128
# File 'lib/rbbt/rest/common/table.rb', line 121

def self.tsv_sort(v)
  value = v.last
  if Array === value
    value.first.to_f
  else
    value.to_f
  end
end

Instance Method Details

#<=>(other) ⇒ Object



111
112
113
114
115
116
117
118
119
# File 'lib/rbbt/rest/common/table.rb', line 111

def <=>(other)
  if Float === self
    super(other.to_f)
  else
    v1 = self.to_f
    v2 = other.to_f
    v1 <=> v2
  end
end

#invalid?Boolean

Returns:

  • (Boolean)


107
108
109
# File 'lib/rbbt/rest/common/table.rb', line 107

def invalid?
  self == "NA" or self == "NaN"
end

#to_sObject



130
131
132
# File 'lib/rbbt/rest/common/table.rb', line 130

def to_s
  self.invalid? ? self : "%.5g" % self.to_f
end