Sha256: ef3aac1d1aff8c63b37cf2f61368a7ad3e9eaf7cd72b1364016f391081510ba5

Contents?: true

Size: 252 Bytes

Versions: 20

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

20 entries across 20 versions & 1 rubygems

Version Path
bolognese-0.9.8 lib/bolognese/array.rb
bolognese-0.9.7 lib/bolognese/array.rb
bolognese-0.9.6 lib/bolognese/array.rb
bolognese-0.9.5 lib/bolognese/array.rb
bolognese-0.9.4 lib/bolognese/array.rb
bolognese-0.9.3 lib/bolognese/array.rb
bolognese-0.9.2 lib/bolognese/array.rb
bolognese-0.9.1 lib/bolognese/array.rb
bolognese-0.9 lib/bolognese/array.rb
bolognese-0.8.13 lib/bolognese/array.rb
bolognese-0.8.12 lib/bolognese/array.rb
bolognese-0.8.11 lib/bolognese/array.rb
bolognese-0.8.10 lib/bolognese/array.rb
bolognese-0.8.7 lib/bolognese/array.rb
bolognese-0.8.5 lib/bolognese/array.rb
bolognese-0.8.4 lib/bolognese/array.rb
bolognese-0.8.3 lib/bolognese/array.rb
bolognese-0.8.2 lib/bolognese/array.rb
bolognese-0.8.1 lib/bolognese/array.rb
bolognese-0.8 lib/bolognese/array.rb