Sha256: da69f988d94f60d269f8500a9cb74c97366ec054a6debfdfc268a76a6d1bc35b

Contents?: true

Size: 632 Bytes

Versions: 4

Compression:

Stored size: 632 Bytes

Contents

require 'forwardable'

require 'hamster/immutable'

module Hamster

  class Tuple

    extend Forwardable

    include Immutable

    def initialize(*items)
      @items = items.freeze
    end

    def first
      @items.first
    end

    def last
      @items.last
    end

    def eql?(other)
      return true if other.equal?(self)
      return false unless other.class.equal?(self.class)
      @items.eql?(other.instance_eval{@items})
    end
    def_delegator :self, :eql?, :==

    def to_ary
      @items
    end

    def to_a
      @items.dup
    end

    def inspect
      "(#{@items.inspect[1..-2]})"
    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hamster-0.3.3 lib/hamster/tuple.rb
hamster-0.3.2 lib/hamster/tuple.rb
hamster-0.3.1 lib/hamster/tuple.rb
hamster-0.3.0 lib/hamster/tuple.rb