Class: RaaP::Sized
- Inherits:
-
Object
- Object
- RaaP::Sized
- Defined in:
- lib/raap/sized.rb
Instance Method Summary collapse
-
#initialize(&block) ⇒ Sized
constructor
A new instance of Sized.
- #pick(size:) ⇒ Object
- #such_that(&block) ⇒ Object (also: #when)
Constructor Details
#initialize(&block) ⇒ Sized
Returns a new instance of Sized.
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 |