Class: Nuggets::Hash::ZipMixin::ZipVal

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/nuggets/hash/zip_mixin.rb

Direct Known Subclasses

ZipKey

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ ZipVal

Returns a new instance of ZipVal.



116
117
118
# File 'lib/nuggets/hash/zip_mixin.rb', line 116

def initialize(value)
  @value = zip(value)
end

Instance Method Details

#<=>(other) ⇒ Object



120
121
122
# File 'lib/nuggets/hash/zip_mixin.rb', line 120

def <=>(other)
  to_s <=> other.to_s if self.class.equal?(other.class)
end

#eql?(other) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


137
138
139
# File 'lib/nuggets/hash/zip_mixin.rb', line 137

def eql?(other)
  (self <=> other) == 0
end

#hashObject



133
134
135
# File 'lib/nuggets/hash/zip_mixin.rb', line 133

def hash
  to_s.hash
end

#inspectObject



128
129
130
131
# File 'lib/nuggets/hash/zip_mixin.rb', line 128

def inspect
  !((s = to_s).length > 64 || s.include?($/)) ? to_s :
    '#<%s:0x%x length=%p>' % [self.class, object_id, @value.length]
end

#to_sObject



124
125
126
# File 'lib/nuggets/hash/zip_mixin.rb', line 124

def to_s
  unzip(@value)
end