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.10.21 lib/bolognese/array.rb
bolognese-0.10.20 lib/bolognese/array.rb
bolognese-0.10.19 lib/bolognese/array.rb
bolognese-0.10.18 lib/bolognese/array.rb
bolognese-0.10.17 lib/bolognese/array.rb
bolognese-0.10.16 lib/bolognese/array.rb
bolognese-0.10.15 lib/bolognese/array.rb
bolognese-0.10.14 lib/bolognese/array.rb
bolognese-0.10.13 lib/bolognese/array.rb
bolognese-0.10.11 lib/bolognese/array.rb
bolognese-0.10.10 lib/bolognese/array.rb
bolognese-0.10.9 lib/bolognese/array.rb
bolognese-0.10.8 lib/bolognese/array.rb
bolognese-0.10.7 lib/bolognese/array.rb
bolognese-0.10.6 lib/bolognese/array.rb
bolognese-0.10.5 lib/bolognese/array.rb
bolognese-0.10.4 lib/bolognese/array.rb
bolognese-0.10.3 lib/bolognese/array.rb
bolognese-0.10.2 lib/bolognese/array.rb
bolognese-0.10 lib/bolognese/array.rb