instance method
to_yaml
Ruby on Rails 3.1.12
Since v3.0.20 Last seen in v3.2.22.5Signature
to_yaml(opts = {})
This emits the number without any scientific notation. This is better than self.to_f.to_s since it doesn’t lose precision.
Note that reconstituting YAML floats to native floats may lose precision.
Parameters
-
optsopt = {}
Source
# File activesupport/lib/active_support/core_ext/big_decimal/conversions.rb, line 18
def to_yaml(opts = {})
return super if defined?(YAML::ENGINE) && !YAML::ENGINE.syck?
YAML.quick_emit(nil, opts) do |out|
string = to_s
out.scalar(YAML_TAG, YAML_MAPPING[string] || string, :plain)
end
end
Defined in activesupport/lib/active_support/core_ext/big_decimal/conversions.rb line 18
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in BigDecimal