class Pry::Command::Cat::InputExpressionFormatter - pry-0.10.1 Documentation

# class Pry::Command::Cat::InputExpressionFormatter

### Attributes

input_expressions[RW]
opts[RW]

### Public Class Methods

new(input_expressions, opts) click to toggle source

    # File lib/pry/commands/cat/input_expression_formatter.rb, line 7
    def initialize(input_expressions, opts)
      @input_expressions = input_expressions
      @opts = opts
    end

### Public Instance Methods

format() click to toggle source

    # File lib/pry/commands/cat/input_expression_formatter.rb, line 12
    def format
      raise CommandError, "No input expressions!" if numbered_input_items.length < 1

      if numbered_input_items.length > 1
        content = ""
        numbered_input_items.each do |i, s|
          content << "#{Helpers::Text.bold(i.to_s)}:\n" << decorate(Pry::Code(s).with_indentation(2)).to_s
        end

        content
      else
        decorate(Pry::Code(selected_input_items.first))
      end
    end