Sha256: 6ed7f5284b88c53d5f6bba97b23f768a4e5e91e4347cae01e6c19495300fcda6

Contents?: true

Size: 398 Bytes

Versions: 435

Compression:

Stored size: 398 Bytes

Contents

unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
  require 'json'
end
defined?(::Complex) or require 'complex'

class Complex
  def self.json_create(object)
    Complex(object['r'], object['i'])
  end

  def as_json(*)
    {
      JSON.create_id => self.class.name,
      'r'            => real,
      'i'            => imag,
    }
  end

  def to_json(*)
    as_json.to_json
  end
end

Version data entries

435 entries across 365 versions & 45 rubygems

Version Path
rb2exe-0.2.1 bin/traveling-ruby-2.2.2/win/lib/ruby/2.2.0/json/add/complex.rb
rb2exe-0.2.1 bin/traveling-ruby-2.2.2/osx/lib/ruby/2.2.0/json/add/complex.rb
rb2exe-0.2.1 bin/traveling-ruby-2.2.2/l32/lib/ruby/2.2.0/json/add/complex.rb
rb2exe-0.2.0 bin/traveling-ruby-2.2.2/osx/lib/ruby/2.2.0/json/add/complex.rb
rb2exe-0.2.0 bin/traveling-ruby-2.2.2/l32/lib/ruby/2.2.0/json/add/complex.rb
rb2exe-0.2.0 bin/traveling-ruby-2.2.2/l64/lib/ruby/2.2.0/json/add/complex.rb
rb2exe-0.2.0 bin/traveling-ruby-2.2.2/win/lib/ruby/2.2.0/json/add/complex.rb
savant-echo-1.0.4 bin/alexa-0.1.2-osx/lib/ruby/lib/ruby/2.2.0/json/add/complex.rb
savant-echo-1.0.1 bin/alexa-0.1.2-osx/lib/ruby/lib/ruby/2.2.0/json/add/complex.rb
savant-echo-0.1.91 bin/alexa-0.1.2-osx/lib/ruby/lib/ruby/2.2.0/json/add/complex.rb
engineyard-serverside-2.6.14 lib/vendor/json_pure/lib/json/add/complex.rb
engineyard-serverside-2.6.13 lib/vendor/json_pure/lib/json/add/complex.rb
engineyard-serverside-2.6.12 lib/vendor/json_pure/lib/json/add/complex.rb
engineyard-serverside-2.6.12.prewut5 lib/vendor/json_pure/lib/json/add/complex.rb
engineyard-serverside-2.6.12.prewut4 lib/vendor/json_pure/lib/json/add/complex.rb
engineyard-serverside-2.6.12.prewut3 lib/vendor/json_pure/lib/json/add/complex.rb
engineyard-serverside-2.6.12.prewut2 lib/vendor/json_pure/lib/json/add/complex.rb
engineyard-serverside-2.6.12.prewut1 lib/vendor/json_pure/lib/json/add/complex.rb
engineyard-serverside-2.6.12.prewut0 lib/vendor/json_pure/lib/json/add/complex.rb
savant-echo-0.1.9 bin/alexa-0.1.2-osx/lib/ruby/lib/ruby/2.2.0/json/add/complex.rb