Class: ThinkingSphinx::FloatFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/thinking_sphinx/float_formatter.rb

Constant Summary collapse

PATTERN =
/(\d+)e\-(\d+)$/

Instance Method Summary collapse

Constructor Details

#initialize(float) ⇒ FloatFormatter

Returns a new instance of FloatFormatter.



6
7
8
# File 'lib/thinking_sphinx/float_formatter.rb', line 6

def initialize(float)
  @float = float
end

Instance Method Details

#fixedObject



10
11
12
13
14
# File 'lib/thinking_sphinx/float_formatter.rb', line 10

def fixed
  return float.to_s unless exponent_present?

  ("%0.#{decimal_places}f" % float).gsub(/0+$/, '')
end