Module | ActiveSupport::CoreExtensions::BigDecimal::Conversions |
In: |
vendor/rails/activesupport/lib/active_support/core_ext/bigdecimal/conversions.rb
|
# File vendor/rails/activesupport/lib/active_support/core_ext/bigdecimal/conversions.rb, line 14 14: def to_formatted_s(format="F") 15: _original_to_s(format) 16: end
# File vendor/rails/activesupport/lib/active_support/core_ext/bigdecimal/conversions.rb, line 19 19: def to_yaml( opts = {} ) 20: YAML::quick_emit( nil, opts ) do |out| 21: # This emits the number without any scientific notation. 22: # I prefer it to using self.to_f.to_s, which would lose precision. 23: # 24: # Note that YAML allows that when reconsituting floats 25: # to native types, some precision may get lost. 26: # There is no full precision real YAML tag that I am aware of. 27: str = self.to_s 28: if str == "Infinity" 29: str = ".Inf" 30: elsif str == "-Infinity" 31: str = "-.Inf" 32: elsif str == "NaN" 33: str = ".NaN" 34: end 35: out.scalar( "tag:yaml.org,2002:float", str, :plain ) 36: end 37: end