Class: RaaP::Sized

Inherits:
Object
  • Object
show all
Defined in:
lib/raap/sized.rb

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Sized

Returns a new instance of Sized.

Raises:

  • (LocalJumpError)


5
6
7
8
9
10
# File 'lib/raap/sized.rb', line 5

def initialize(&block)
  raise LocalJumpError, "no block given" unless block

  @block = block
  @such_that = nil
end

Instance Method Details

#pick(size:) ⇒ Object



12
13
14
15
16
# File 'lib/raap/sized.rb', line 12

def pick(size:)
  such_that_loop do |skip|
    @block.call(size + skip)
  end
end

#such_that(&block) ⇒ Object Also known as: when



18
19
20
21
# File 'lib/raap/sized.rb', line 18

def such_that(&block)
  @such_that = block
  self
end