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.



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

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

Instance Method Details

#<=>(other) ⇒ Object



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

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

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

Returns:

  • (Boolean)


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

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

#hashObject



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

def hash
  to_s.hash
end

#inspectObject



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

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



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

def to_s
  unzip(@value)
end