class Pry::Command::Ls::Formatter

Attributes

_pry_[R]
grep[W]

Public Class Methods

new(_pry_) click to toggle source
# File lib/pry/commands/ls/formatter.rb, line 7
def initialize(_pry_)
  @_pry_ = _pry_
  @target = _pry_.current_context
  @default_switch = nil
end

Public Instance Methods

write_out() click to toggle source
# File lib/pry/commands/ls/formatter.rb, line 13
def write_out
  return false unless correct_opts?

  output_self
end

Private Instance Methods

color(type, str) click to toggle source
# File lib/pry/commands/ls/formatter.rb, line 21
def color(type, str)
  Pry::Helpers::Text.send _pry_.config.ls["#{type}_color"], str
end
correct_opts?() click to toggle source
# File lib/pry/commands/ls/formatter.rb, line 38
def correct_opts?
  @default_switch
end
format_value(value) click to toggle source
# File lib/pry/commands/ls/formatter.rb, line 34
def format_value(value)
  Pry::ColorPrinter.pp(value, '')
end
grep() click to toggle source
# File lib/pry/commands/ls/formatter.rb, line 46
def grep
  @grep || proc { |x| x }
end
output_section(heading, body) click to toggle source

Add a new section to the output. Outputs nothing if the section would be empty.

# File lib/pry/commands/ls/formatter.rb, line 27
def output_section(heading, body)
  return '' if body.compact.empty?

  fancy_heading = Pry::Helpers::Text.bold(color(:heading, heading))
  Pry::Helpers.tablify_or_one_line(fancy_heading, body, @_pry_.config)
end
output_self() click to toggle source
# File lib/pry/commands/ls/formatter.rb, line 42
def output_self
  raise NotImplementedError
end