Class: Pager
- Inherits:
-
Object
- Object
- Pager
- Defined in:
- lib/pager.rb
Constant Summary collapse
- PAGER_CMD =
"less"
- PAGER_ENV =
{ "LESS" => "FRX", "LV" => "-c" }
Instance Attribute Summary collapse
-
#input ⇒ Object
readonly
Returns the value of attribute input.
Instance Method Summary collapse
-
#initialize(env = {}, stdout = $stdout, stderr = $stderr) ⇒ Pager
constructor
A new instance of Pager.
- #wait ⇒ Object
Constructor Details
#initialize(env = {}, stdout = $stdout, stderr = $stderr) ⇒ Pager
Returns a new instance of Pager.
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/pager.rb', line 7 def initialize(env = {}, stdout = $stdout, stderr = $stderr) env = PAGER_ENV.merge(env) cmd = env["GIT_PAGER"] || env["PAGER"] || PAGER_CMD reader, writer = IO.pipe = { :in => reader, :out => stdout, :err => stderr } @pid = Process.spawn(env, cmd, ) @input = writer reader.close end |
Instance Attribute Details
#input ⇒ Object (readonly)
Returns the value of attribute input.
5 6 7 |
# File 'lib/pager.rb', line 5 def input @input end |
Instance Method Details
#wait ⇒ Object
20 21 22 23 |
# File 'lib/pager.rb', line 20 def wait Process.waitpid(@pid) if @pid @pid = nil end |