Sha256: 9a5499f8bca008ca3f909abf7a3e3b295757ee1b993bb497d8d9d3b38176cb54

Contents?: true

Size: 414 Bytes

Versions: 435

Compression:

Stored size: 414 Bytes

Contents

unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
  require 'json'
end
defined?(::Rational) or require 'rational'

class Rational
  def self.json_create(object)
    Rational(object['n'], object['d'])
  end

  def as_json(*)
    {
      JSON.create_id => self.class.name,
      'n'            => numerator,
      'd'            => denominator,
    }
  end

  def to_json(*)
    as_json.to_json
  end
end

Version data entries

435 entries across 365 versions & 45 rubygems

Version Path
engineyard-serverside-2.8.0 lib/vendor/json_pure/lib/json/add/rational.rb
engineyard-serverside-2.8.0.pre4 lib/vendor/json_pure/lib/json/add/rational.rb
engineyard-serverside-2.8.0.pre3 lib/vendor/json_pure/lib/json/add/rational.rb
engineyard-serverside-2.8.0.pre2 lib/vendor/json_pure/lib/json/add/rational.rb
scout-5.9.13 vendor/json_pure/lib/json/add/rational.rb
engineyard-serverside-2.8.0.pre lib/vendor/json_pure/lib/json/add/rational.rb
engineyard-serverside-2.7.0.pre lib/vendor/json_pure/lib/json/add/rational.rb
engineyard-serverside-2.6.19 lib/vendor/json_pure/lib/json/add/rational.rb
rb2exe-0.3.1 bin/traveling-ruby-2.2.2/osx/lib/ruby/2.2.0/json/add/rational.rb
rb2exe-0.3.1 bin/traveling-ruby-2.2.2/win/lib/ruby/2.2.0/json/add/rational.rb
rb2exe-0.3.1 bin/traveling-ruby-2.2.2/l64/lib/ruby/2.2.0/json/add/rational.rb
rb2exe-0.3.1 bin/traveling-ruby-2.2.2/l32/lib/ruby/2.2.0/json/add/rational.rb
engineyard-serverside-2.6.17 lib/vendor/json_pure/lib/json/add/rational.rb
engineyard-serverside-2.6.16 lib/vendor/json_pure/lib/json/add/rational.rb
scout-5.9.12 vendor/json_pure/lib/json/add/rational.rb
engineyard-serverside-2.6.15.alpha1 lib/vendor/json_pure/lib/json/add/rational.rb
engineyard-serverside-2.6.15.cf2 lib/vendor/json_pure/lib/json/add/rational.rb
engineyard-serverside-2.6.15.pre lib/vendor/json_pure/lib/json/add/rational.rb
scout-5.9.11 vendor/json_pure/lib/json/add/rational.rb
rb2exe-0.3.0 bin/traveling-ruby-2.2.2/osx/lib/ruby/2.2.0/json/add/rational.rb