Sha256: c19c26cad20dbc603d946f63005636548b01eef9d215f7cbb3efb652305fcb35

Contents?: true

Size: 560 Bytes

Versions: 1

Compression:

Stored size: 560 Bytes

Contents

# frozen_string_literal: true

class Revector
  module Exists
    def self.check!(item, iteratee)
      compare(Utility::TryFetchOrBlank[item, iteratee])
    end

    def self.compare(value, other = false)
      case value
      in [*] | String
        value.size.positive?.to_s == other.to_s
      else
        !!value.to_s == other.to_s
      end
    end
  end

  module NotExists
    def self.check!(item, iteratee)
      !Exists.check!(item, iteratee)
    end

    def self.compare(value, other = nil)
      !Exists.compare(value, other)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
revector-0.1.2 lib/revector/predicate/exists.rb