Sha256: 6ba5000910920b4576f86931132eec204ad7ded607e143d516a9317d9fe2d4fb

Contents?: true

Size: 294 Bytes

Versions: 2

Compression:

Stored size: 294 Bytes

Contents

# frozen_string_literal: true

class Symbol
  def clamped(whitelist, strict: true, default: nil)
    is_included = proc do |item|
      if strict
        item == self
      else
        item.to_sym == self
      end
    end

    return self if whitelist.any?(is_included)
    default
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
clamped-1.0.1 lib/clamped/symbol.rb
clamped-1.0.0 lib/clamped/symbol.rb