Class: Float

Inherits:
Object show all
Defined in:
vendor/bundler/ruby/3.3.0/bundler/gems/sxp.rb-7a771a32c5fe/lib/sxp/extensions.rb

Overview

Extensions for Ruby's Float class.

Instance Method Summary collapse

Instance Method Details

#to_sxp(**options) ⇒ String

Returns the SXP representation of this object.

Returns:



149
150
151
152
153
154
155
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/sxp.rb-7a771a32c5fe/lib/sxp/extensions.rb', line 149

def to_sxp(**options)
  case
    when nan? then 'nan.0'
    when infinite? then (infinite? > 0 ? '+inf.0' : '-inf.0')
    else to_s
  end
end