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.58 lib/bolognese/array.rb
bolognese-0.9.56 lib/bolognese/array.rb
bolognese-0.9.55 lib/bolognese/array.rb
bolognese-0.9.54 lib/bolognese/array.rb
bolognese-0.9.52 lib/bolognese/array.rb
bolognese-0.9.51 lib/bolognese/array.rb
bolognese-0.9.50 lib/bolognese/array.rb
bolognese-0.9.48 lib/bolognese/array.rb
bolognese-0.9.44 lib/bolognese/array.rb
bolognese-0.9.43 lib/bolognese/array.rb
bolognese-0.9.42 lib/bolognese/array.rb
bolognese-0.9.41 lib/bolognese/array.rb
bolognese-0.9.39 lib/bolognese/array.rb
bolognese-0.9.38 lib/bolognese/array.rb
bolognese-0.9.37 lib/bolognese/array.rb
bolognese-0.9.36 lib/bolognese/array.rb
bolognese-0.9.35 lib/bolognese/array.rb
bolognese-0.9.34 lib/bolognese/array.rb
bolognese-0.9.33 lib/bolognese/array.rb
bolognese-0.9.32 lib/bolognese/array.rb