instance method to_yaml

Ruby on Rails 3.0.20

Since v3.0.20 Last seen in v3.2.22.5

Available in: v3.0.20 v3.1.12 v3.2.22.5

Signature

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

opts opt = {}
Source
# File activesupport/lib/active_support/core_ext/big_decimal/conversions.rb, line 20
  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 20 · View on GitHub · Improve this page · Find usages on GitHub

Defined in BigDecimal

Type at least 2 characters to search.

↑↓ navigate · open · esc close