Class: RubyJard::Pager

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_jard/pager.rb

Overview

Override Pry’s pager system. Again, Pry doesn’t support customizing pager. So…

Defined Under Namespace

Classes: JardPageTracker, LessPager

Instance Method Summary collapse

Constructor Details

#initialize(pry_instance) ⇒ Pager

Returns a new instance of Pager.



7
8
9
# File 'lib/ruby_jard/pager.rb', line 7

def initialize(pry_instance)
  @pry_instance = pry_instance
end

Instance Method Details

#open(options = {}) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/ruby_jard/pager.rb', line 17

def open(options = {})
  pager = LessPager.new(@pry_instance, **options)
  yield pager
rescue Pry::Pager::StopPaging
  # Ignore
ensure
  pager.close
end

#page(text) ⇒ Object



11
12
13
14
15
# File 'lib/ruby_jard/pager.rb', line 11

def page(text)
  open do |pager|
    pager << text
  end
end