Module: Toys::StandardMixins::Pager
- Includes:
- Mixin
- Defined in:
- lib/toys/standard_mixins/pager.rb
Overview
A mixin that provides a pager.
This mixin provides an instance of Utils::Pager, which invokes an external pager for output.
You can also pass additional keyword arguments to the include
directive
to configure the pager object. These will be passed on to
Utils::Pager#initialize.
Constant Summary collapse
- KEY =
Context key for the Pager object.
::Object.new.freeze
Instance Method Summary collapse
-
#pager(&block) ⇒ Toys::Utils::Pager, Integer
Access the Pager.
Methods included from Mixin
Instance Method Details
#pager(&block) ⇒ Toys::Utils::Pager, Integer
Access the Pager.
If no block is given, returns the pager object.
If a block is given, the pager is executed with the given block, and the exit code of the pager process is returned.
45 46 47 48 49 |
# File 'lib/toys/standard_mixins/pager.rb', line 45 def pager(&block) pager = self[KEY] return pager unless block self[KEY].start(&block) end |