Sha256: ad95ce63bd611304d6bdc91500e6e674fdff30a9aa770fcbcca043863f37eda9

Contents?: true

Size: 252 Bytes

Versions: 102

Compression:

Stored size: 252 Bytes

Contents

# turn array into hash or nil, depending on array size.
# Reverses Array.wrap, but uses self to allow chaining with Array.wrap
class Array
  def unwrap
    case self.length
    when 0 then nil
    when 1 then self.first
    else self
    end
  end
end

Version data entries

102 entries across 102 versions & 1 rubygems

Version Path
bolognese-0.9.99 lib/bolognese/array.rb
bolognese-0.9.98 lib/bolognese/array.rb
bolognese-0.9.97 lib/bolognese/array.rb
bolognese-0.9.96 lib/bolognese/array.rb
bolognese-0.9.95 lib/bolognese/array.rb
bolognese-0.9.94 lib/bolognese/array.rb
bolognese-0.9.93 lib/bolognese/array.rb
bolognese-0.9.92 lib/bolognese/array.rb
bolognese-0.9.91 lib/bolognese/array.rb
bolognese-0.9.89 lib/bolognese/array.rb
bolognese-0.9.88 lib/bolognese/array.rb
bolognese-0.9.87 lib/bolognese/array.rb
bolognese-0.9.86 lib/bolognese/array.rb
bolognese-0.9.85 lib/bolognese/array.rb
bolognese-0.9.84 lib/bolognese/array.rb
bolognese-0.9.83 lib/bolognese/array.rb
bolognese-0.9.82 lib/bolognese/array.rb
bolognese-0.9.81 lib/bolognese/array.rb
bolognese-0.9.80 lib/bolognese/array.rb
bolognese-0.9.79 lib/bolognese/array.rb