Sha256: a947eb263bcedd9e1a41d6ef91d7925009d1727638c2a1c6b1f9b82ee34ef283

Contents?: true

Size: 586 Bytes

Versions: 10

Compression:

Stored size: 586 Bytes

Contents

module Finitio
  module HeadingBasedType

    def initialize(heading, name = nil, metadata = nil)
      unless heading.is_a?(Heading)
        raise ArgumentError, "Heading expected, got `#{heading}`"
      end

      super(name, metadata)
      @heading = heading
    end
    attr_reader :heading

    def [](attrname)
      heading.fetch(attrname)
    end

    def ==(other)
      super || (other.is_a?(self.class) && heading == other.heading)
    end
    alias :eql? :==

    def hash
      self.class.hash ^ heading.hash
    end

  end # module HeadingBasedType
end # module Finitio

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
finitio-0.7.0 lib/finitio/type/heading_based_type.rb
finitio-0.7.0.pre.rc4 lib/finitio/type/heading_based_type.rb
finitio-0.7.0.pre.rc3 lib/finitio/type/heading_based_type.rb
finitio-0.7.0.pre.rc2 lib/finitio/type/heading_based_type.rb
finitio-0.7.0.pre.rc1 lib/finitio/type/heading_based_type.rb
finitio-0.6.1 lib/finitio/type/heading_based_type.rb
finitio-0.6.0 lib/finitio/type/heading_based_type.rb
finitio-0.5.2 lib/finitio/type/heading_based_type.rb
finitio-0.5.1 lib/finitio/type/heading_based_type.rb
finitio-0.5.0 lib/finitio/type/heading_based_type.rb