Class: Yargi::TagPredicate

Inherits:
Predicate show all
Defined in:
lib/yargi/predicate.rb

Overview

Decorates a module instance as a predicate

Constant Summary

Constants inherited from Predicate

Predicate::ALL, Predicate::NONE

Instance Method Summary collapse

Methods inherited from Predicate

#&, #not, to_predicate, #|

Constructor Details

#initialize(mod) ⇒ TagPredicate

Creates a Tag predicate

Raises:

  • (ArgumentError)


97
98
99
100
# File 'lib/yargi/predicate.rb', line 97

def initialize(mod)
  raise ArgumentError, "Module expected, #{mod} received" unless Module===mod
  @mod = mod
end

Instance Method Details

#===(elm) ⇒ Object

Predicate implementation



103
104
105
# File 'lib/yargi/predicate.rb', line 103

def ===(elm)
  @mod===elm
end

#inspectObject

Helps debugging predicates



108
109
110
# File 'lib/yargi/predicate.rb', line 108

def inspect
  "is_a?(#{@mod})"
end