Module: PryState::Printer

Extended by:
Printer
Included in:
Printer
Defined in:
lib/pry-state/printer.rb

Constant Summary collapse

WIDTH =
ENV['COLUMNS'] ? ENV['COLUMNS'].to_i : 80
MAX_LEFT_COLUMN_WIDTH =
25
COLUMN_RATIO =

Ratios are 1:3 left:right, or 1/4 left

3
LEFT_COLUMN_WIDTH =

right column to left ratio

[(WIDTH / (COLUMN_RATIO + 1)).floor, MAX_LEFT_COLUMN_WIDTH].min
TRUNCATE =

Defaults to true

ENV['PRY_STATE_TRUNCATE'] != 'false'

Instance Method Summary collapse

Instance Method Details

#trunc_and_print(var, value, var_color, value_color) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/pry-state/printer.rb', line 14

def trunc_and_print var, value, var_color, value_color
  var_name_adjusted = var.to_s.ljust(LEFT_COLUMN_WIDTH)
  # Ensure at least 1 space between left and right columns
  left_column_text = truncate(var_name_adjusted, LEFT_COLUMN_WIDTH - 1) + ' '
  print Pry::Helpers::Text.send(var_color, left_column_text)
  print stringified_val_or_nil(value, value_color, WIDTH - LEFT_COLUMN_WIDTH)
  print "\n"
end