Class: Hubkit::NotCollection

Inherits:
Object
  • Object
show all
Defined in:
lib/hubkit/chainable_collection.rb

Overview

A collection that lets you perform the inverse of a filter

Examples:

repo.issues.not.labeled('in progress')

Instance Method Summary collapse

Constructor Details

#initialize(base) ⇒ NotCollection

Returns a new instance of NotCollection.


88
89
90
# File 'lib/hubkit/chainable_collection.rb', line 88

def initialize(base)
  @base = base
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) {|...| ... } ⇒ ChainableCollection

Any method of this class will be delegated down to the original ChainableCollection. The result of the method will be a ChainableCollection which contains all the elements not returned by the filter called.

Parameters:

  • name (String, Symbol)

    the name of the method being called

  • args (Array)

    the arguments to the method being called

Yield Parameters:

  • ...

    the parameters of the any block given to the method which is being called

Returns:

  • (ChainableCollection)

    all elements which do not match the chained filter in a new ChainableCollection


102
103
104
# File 'lib/hubkit/chainable_collection.rb', line 102

def method_missing(name, *args, &block)
  @base.wrap(@base - @base.send(name, *args, &block))
end