Class: Axiom::Function::Predicate::Inclusion

Inherits:
Axiom::Function::Predicate show all
Includes:
Enumerable
Defined in:
lib/axiom/function/predicate/inclusion.rb

Overview

A predicate representing an inclusion test

Defined Under Namespace

Modules: Methods

Instance Attribute Summary

Attributes included from Operation::Binary

#left, #right

Class Method Summary collapse

Methods included from Enumerable

#call, compare_method

Methods inherited from Axiom::Function::Predicate

type

Methods included from Binary::Invertible

#inverse

Methods included from Binary

#call, #rename, #type

Methods included from Operation::Binary

#initialize

Methods included from Connective::Conjunction::Methods

#and

Methods included from Aliasable

#inheritable_alias

Methods included from Connective::Disjunction::Methods

#or

Methods included from Connective::Negation::Methods

#not

Methods inherited from Axiom::Function

extract_value, rename_attributes, #type

Methods included from Visitable

#accept

Class Method Details

.call(left, right) ⇒ Boolean

Test an enumerable to see if a value is included

Examples:

Inclusion.call(1, [1, 2, 3])  # => true

Parameters:

  • left (Object)

    the object to test for in the Enumerable

  • right (Enumerable)

    the enumerable to test

Returns:

  • (Boolean)


24
25
26
# File 'lib/axiom/function/predicate/inclusion.rb', line 24

def self.call(left, right)
  right.public_send(Enumerable.compare_method(right), left)
end

.inverseClass<Exclusion>

Return the inverse predicate class

Examples:

Inclusion.inverse  # => Exclusion

Returns:



36
37
38
# File 'lib/axiom/function/predicate/inclusion.rb', line 36

def self.inverse
  Exclusion
end