Class: Byebug::Printers::Plain
- Includes:
- Columnize
- Defined in:
- lib/byebug/printers/plain.rb
Constant Summary
Constants inherited from Base
Instance Method Summary collapse
- #print(path, args = {}) ⇒ Object
- #print_collection(path, collection, &block) ⇒ Object
- #print_variables(variables) ⇒ Object
Methods inherited from Base
Instance Method Details
#print(path, args = {}) ⇒ Object
8 9 10 11 12 |
# File 'lib/byebug/printers/plain.rb', line 8 def print(path, args = {}) = translate(locate(path), args) tail = parts(path).include?('confirmations') ? ' (y/n) ' : "\n" << tail end |
#print_collection(path, collection, &block) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/byebug/printers/plain.rb', line 14 def print_collection(path, collection, &block) modifier = get_modifier(path) lines = array_of_args(collection, &block).map do |args| print(path, args) end if modifier == 'c' columnize(lines.map { |l| l.gsub(/\n$/, '') }, Setting[:width]) else lines.join('') end end |
#print_variables(variables) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/byebug/printers/plain.rb', line 27 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 |