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
classiccms-0.5.0 vendor/bundle/gems/json-1.7.3/lib/json/add/complex.rb
json-1.7.4-java lib/json/add/complex.rb
json_pure-1.7.4 lib/json/add/complex.rb
json-1.7.4 lib/json/add/complex.rb
classiccms-0.4.2 vendor/bundle/gems/json-1.7.3/lib/json/add/complex.rb
classiccms-0.4.1 vendor/bundle/gems/json-1.7.3/lib/json/add/complex.rb
classiccms-0.4.0 vendor/bundle/gems/json-1.7.3/lib/json/add/complex.rb
classiccms-0.3.9 vendor/bundle/gems/json-1.7.3/lib/json/add/complex.rb
challah-0.6.2 vendor/bundle/gems/json-1.6.5/lib/json/add/complex.rb
challah-0.6.2 vendor/bundle/gems/json-1.7.3/lib/json/add/complex.rb
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/rails-uploader-0.0.1/vendor/bundle/ruby/1.9.1/gems/json-1.7.1/lib/json/add/complex.rb
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/json-1.7.3/lib/json/add/complex.rb
initforthe-cookies-0.0.1 vendor/bundle/gems/json-1.7.3/lib/json/add/complex.rb
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/rails-uploader-0.0.1/vendor/bundle/ruby/1.9.1/gems/json-1.7.1/lib/json/add/complex.rb
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/json-1.7.3/lib/json/add/complex.rb
sunrise-cms-0.3.1 vendor/bundle/ruby/1.9.1/gems/rails-uploader-0.0.1/vendor/bundle/ruby/1.9.1/gems/json-1.7.1/lib/json/add/complex.rb
sunrise-cms-0.3.1 vendor/bundle/ruby/1.9.1/gems/json-1.7.3/lib/json/add/complex.rb
sunrise-cms-0.3.0 vendor/bundle/ruby/1.9.1/gems/rails-uploader-0.0.1/vendor/bundle/ruby/1.9.1/gems/json-1.7.1/lib/json/add/complex.rb
sunrise-cms-0.3.0 vendor/bundle/ruby/1.9.1/gems/json-1.7.3/lib/json/add/complex.rb
rails-uploader-0.0.4 vendor/bundle/ruby/1.9.1/gems/json-1.7.1/lib/json/add/complex.rb