Class: MediaTypes::Scheme::OutputIteratorWithPredicate
- Inherits:
-
Object
- Object
- MediaTypes::Scheme::OutputIteratorWithPredicate
- Defined in:
- lib/media_types/scheme/output_iterator_with_predicate.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#call ⇒ Object
Mimics Enumerable#all? with mandatory &block.
-
#initialize(enumerable, options, rules:) ⇒ OutputIteratorWithPredicate
constructor
A new instance of OutputIteratorWithPredicate.
Constructor Details
#initialize(enumerable, options, rules:) ⇒ OutputIteratorWithPredicate
Returns a new instance of OutputIteratorWithPredicate.
15 16 17 18 19 |
# File 'lib/media_types/scheme/output_iterator_with_predicate.rb', line 15 def initialize(enumerable, , rules:) self.enumerable = enumerable self. = self.rules = rules end |
Class Method Details
.call(*args, **opts, &block) ⇒ Object
10 11 12 |
# File 'lib/media_types/scheme/output_iterator_with_predicate.rb', line 10 def call(*args, **opts, &block) new(*args, **opts).call(&block) end |
Instance Method Details
#call ⇒ Object
Mimics Enumerable#all? with mandatory &block
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/media_types/scheme/output_iterator_with_predicate.rb', line 24 def call if hash? return iterate_hash { |*args, **opts| yield(*args, **opts) } end if array? return iterate { |*args, **opts| yield(*args, **opts) } end raise "Internal consistency error, unexpected: #{enumerable.class}" end |