Sha256: 0579270871c1ce95af6c592d28a0b625c1fcb01e3e953ec01348fe4b4ce83914

Contents?: true

Size: 283 Bytes

Versions: 212

Compression:

Stored size: 283 Bytes

Contents

# frozen_string_literal: true

# 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

212 entries across 212 versions & 2 rubygems

Version Path
bolognese-2.3.2 lib/bolognese/array.rb
bolognese-2.3.0 lib/bolognese/array.rb
bolognese-2.2.0 lib/bolognese/array.rb
bolognese-2.1.1 lib/bolognese/array.rb
bolognese-2.1.0 lib/bolognese/array.rb
bolognese-2.0.3 lib/bolognese/array.rb
bolognese-2.0.2 lib/bolognese/array.rb
bolognese-2.0.1 lib/bolognese/array.rb
bolognese-2.0.0 lib/bolognese/array.rb
bolognese-1.11.5 lib/bolognese/array.rb
bolognese-1.11.4 lib/bolognese/array.rb
bolognese-1.11.3 lib/bolognese/array.rb
bolognese-1.11.2 lib/bolognese/array.rb
bolognese-1.11.0 lib/bolognese/array.rb
bolognese-1.10.0 lib/bolognese/array.rb
bolognese-1.9.18 lib/bolognese/array.rb
briard-2.4.2 lib/briard/array.rb
briard-2.4.1 lib/briard/array.rb
briard-2.4 lib/briard/array.rb
briard-2.3.1 lib/briard/array.rb