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



140
141
142
143
144
145
146
147
# File 'lib/rbbt/rest/common/table.rb', line 140

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



130
131
132
133
134
135
136
137
138
# File 'lib/rbbt/rest/common/table.rb', line 130

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)


126
127
128
# File 'lib/rbbt/rest/common/table.rb', line 126

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

#to_sObject



149
150
151
# File 'lib/rbbt/rest/common/table.rb', line 149

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