123456789_123456789_123456789_123456789_123456789_

Class: RBS::UnitTest::WithAliases::WithEnum

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
self, Enumerable
Inherits: Object
Defined in: lib/rbs/unit_test/with_aliases.rb

Class Method Summary

Instance Method Summary

Constructor Details

.new(enum) ⇒ WithEnum

[ GitHub ]

  
# File 'lib/rbs/unit_test/with_aliases.rb', line 11

def initialize(enum) = @enum = enum

Instance Method Details

#and(*args, &block)

[ GitHub ]

  
# File 'lib/rbs/unit_test/with_aliases.rb', line 27

def and(*args, &block)
  return WithEnum.new to_enum(__method__ || raise, *args) unless block

  each(&block)
  args.each do |arg|
    if WithEnum === arg # use `===` as `arg` might not have `.is_a?` on it
      arg.each(&block)
    else
      block.call(_ = arg)
    end
  end
end

#and_nil(&block)

[ GitHub ]

  
# File 'lib/rbs/unit_test/with_aliases.rb', line 15

def and_nil(&block)
  self.and(nil, &_ = block)
end

#but(*cases, &block)

[ GitHub ]

  
# File 'lib/rbs/unit_test/with_aliases.rb', line 19

def but(*cases, &block)
  return WithEnum.new to_enum(__method__ || raise, *cases) unless block

  each do |arg|
    yield arg unless cases.any? { (_ = _1) === arg }
  end
end

#each(&block)

[ GitHub ]

  
# File 'lib/rbs/unit_test/with_aliases.rb', line 13

def each(&block) = @enum.each(&block)