class Byebug::Printers::Plain - byebug-4.0.5 Documentation

# class Byebug::Printers::Plain

### Public Instance Methods

print(path, args = {}) click to toggle source

    # File lib/byebug/printers/plain.rb, line 8
    def print(path, args = {})
      message = translate(locate(path), args)
      tail = parts(path).include?('confirmations') ? ' (y/n) ' : "\n"
      message << tail
    end

print_collection(path, collection, &block) click to toggle source

    # 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) click to toggle source

    # 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

### Private Instance Methods

contents_files() click to toggle source
Calls superclass method Byebug::Printers::Base#contents_files

    # File lib/byebug/printers/plain.rb, line 47
    def contents_files
      [File.expand_path(File.join('..', 'texts', 'plain.yml'), __FILE__)] +
        super
    end

get_modifier(path) click to toggle source

    # File lib/byebug/printers/plain.rb, line 41
    def get_modifier(path)
      modifier_regexp = /\|(\w+)$/
      modifier_match = locate(path).match(modifier_regexp)
      modifier_match && modifier_match[1]
    end