Module: Pry::Helpers

Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/pry-0.14.2/lib/pry/helpers/text.rb,
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/pry-0.14.2/lib/pry/helpers/table.rb,
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/pry-0.14.2/lib/pry/helpers/platform.rb,
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/pry-0.14.2/lib/pry/helpers/base_helpers.rb,
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/pry-0.14.2/lib/pry/helpers/command_helpers.rb,
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/pry-0.14.2/lib/pry/helpers/options_helpers.rb,
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/pry-0.14.2/lib/pry/helpers/documentation_helpers.rb

Defined Under Namespace

Modules: BaseHelpers, CommandHelpers, DocumentationHelpers, OptionsHelpers, Platform, Text Classes: Table

Class Method Summary collapse

Class Method Details

.tablify(things, line_length, pry_instance = Pry.new) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/pry-0.14.2/lib/pry/helpers/table.rb', line 27

def self.tablify(things, line_length, pry_instance = Pry.new)
  table = Table.new(things, { column_count: things.size }, pry_instance)
  until (table.column_count == 1) || table.fits_on_line?(line_length)
    table.column_count -= 1
  end
  table
end

.tablify_or_one_line(heading, things, pry_instance = Pry.new) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/pry-0.14.2/lib/pry/helpers/table.rb', line 5

def self.tablify_or_one_line(heading, things, pry_instance = Pry.new)
  plain_heading = Pry::Helpers::Text.strip_color(heading)
  attempt = Table.new(things, column_count: things.size)
  if attempt.fits_on_line?(pry_instance.output.width - plain_heading.size - 2)
    "#{heading}: #{attempt}\n"
  else
    content = tablify_to_screen_width(things, { indent: '  ' }, pry_instance)
    "#{heading}: \n#{content}\n"
  end
end

.tablify_to_screen_width(things, options, pry_instance = Pry.new) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/pry-0.14.2/lib/pry/helpers/table.rb', line 16

def self.tablify_to_screen_width(things, options, pry_instance = Pry.new)
  options ||= {}
  things = things.compact
  if (indent = options[:indent])
    usable_width = pry_instance.output.width - indent.size
    tablify(things, usable_width, pry_instance).to_s.gsub(/^/, indent)
  else
    tablify(things, pry_instance.output.width, pry_instance).to_s
  end
end