Class: ThinkingSphinx::FloatFormatter
- Inherits:
-
Object
- Object
- ThinkingSphinx::FloatFormatter
- Defined in:
- lib/thinking_sphinx/float_formatter.rb
Constant Summary collapse
- PATTERN =
/(\d+)e\-(\d+)$/
Instance Method Summary collapse
- #fixed ⇒ Object
-
#initialize(float) ⇒ FloatFormatter
constructor
A new instance of FloatFormatter.
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
#fixed ⇒ Object
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 |