Sha256: 11be0f90de04510cb726b60436069628956adc7f91e283925ba156a260da42d2

Contents?: true

Size: 621 Bytes

Versions: 20

Compression:

Stored size: 621 Bytes

Contents

# encoding: utf-8
module TestServer
  class Encoder
    include Comparable

    def name
      self.class.to_s.demodulize.underscore.to_sym
    end

    def encode(string)
      fail NotImplementedError, JSON.dump(method: 'encode')
    end

    def decode(string)
      fail NotImplementedError, JSON.dump(method: 'decode')
    end

    def name?(n)
      name == n
    end

    def eql?(other)
      name? other.name
    end

    def hash
      Digest::SHA1.hexdigest name.to_s
    end

    def <=>(other)
      name <=> other.name
    end

    def find_by_name(name)
    rescue NameError
      raise 
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
test_server-0.5.2 lib/test_server/encoder.rb
test_server-0.5.1 lib/test_server/encoder.rb
test_server-0.5.0 lib/test_server/encoder.rb
test_server-0.4.1 lib/test_server/encoder.rb
test_server-0.4.0 lib/test_server/encoder.rb
test_server-0.3.7 lib/test_server/encoder.rb
test_server-0.3.6 lib/test_server/encoder.rb
test_server-0.3.5 lib/test_server/encoder.rb
test_server-0.3.4 lib/test_server/encoder.rb
test_server-0.3.2 lib/test_server/encoder.rb
test_server-0.3.1 lib/test_server/encoder.rb
test_server-0.2.4 lib/test_server/encoder.rb
test_server-0.2.3 lib/test_server/encoder.rb
test_server-0.2.2 lib/test_server/encoder.rb
test_server-0.2.1 lib/test_server/encoder.rb
test_server-0.2.0 lib/test_server/encoder.rb
test_server-0.1.2 lib/test_server/encoder.rb
test_server-0.1.1 lib/test_server/encoder.rb
test_server-0.1.0 lib/test_server/encoder.rb
test_server-0.0.11 lib/test_server/encoder.rb