Class: Byebug::Printers::Plain

Inherits:
Base
  • Object
show all
Defined in:
lib/byebug/printers/plain.rb

Overview

Plain text printer

Constant Summary

Constants inherited from Base

Base::SEPARATOR

Instance Method Summary collapse

Methods inherited from Base

#type

Instance Method Details



9
10
11
12
13
# File 'lib/byebug/printers/plain.rb', line 9

def print(path, args = {})
  message = translate(locate(path), args)
  tail = parts(path).include?('confirmations') ? ' (y/n) ' : "\n"
  message << tail
end


15
16
17
18
19
20
21
# File 'lib/byebug/printers/plain.rb', line 15

def print_collection(path, collection, &block)
  lines = array_of_args(collection, &block).map do |args|
    print(path, args)
  end

  lines.join
end


23
24
25
26
27
28
29
30
31
32
33
# File 'lib/byebug/printers/plain.rb', line 23

def print_variables(variables, *_)
  print_collection('variable.variable', variables) do |(key, value), _|
    value = value.nil? ? 'nil' : value.to_s
    if "#{key} = #{value}".size > Setting[:width]
      key_size = "#{key} = ".size
      value = value[0..Setting[:width] - key_size - 4] + '...'
    end

    { key: key, value: value }
  end
end