Sha256: ac21ad71a89c5225d4bd44c95f3943affacec55a4b3a6a599098ae3acf2f7e51

Contents?: true

Size: 1.13 KB

Versions: 155

Compression:

Stored size: 1.13 KB

Contents

class Pry
  class Command::Cat
    class InputExpressionFormatter < AbstractFormatter
      attr_accessor :input_expressions
      attr_accessor :opts

      def initialize(input_expressions, opts)
        @input_expressions = input_expressions
        @opts = opts
      end

      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

      private

      def selected_input_items
        input_expressions[normalized_expression_range] || []
      end

      def numbered_input_items
        @numbered_input_items ||= normalized_expression_range.zip(selected_input_items).
          reject { |_, s| s.nil? || s == "" }
      end

      def normalized_expression_range
        absolute_index_range(opts[:i], input_expressions.length)
      end
    end
  end
end

Version data entries

155 entries across 148 versions & 35 rubygems

Version Path
logstash-output-scalyr-0.2.1.beta vendor/bundle/jruby/2.5.0/gems/pry-0.10.4-java/lib/pry/commands/cat/input_expression_formatter.rb
logstash-output-scalyr-0.2.0 vendor/bundle/jruby/2.5.0/gems/pry-0.10.4-java/lib/pry/commands/cat/input_expression_formatter.rb
logstash-output-scalyr-0.2.0.beta vendor/bundle/jruby/2.5.0/gems/pry-0.10.4-java/lib/pry/commands/cat/input_expression_formatter.rb
logstash-output-scalyr-0.1.26.beta vendor/bundle/jruby/2.5.0/gems/pry-0.10.4-java/lib/pry/commands/cat/input_expression_formatter.rb
logstash-output-scalyr-0.1.25.beta vendor/bundle/jruby/2.5.0/gems/pry-0.10.4-java/lib/pry/commands/cat/input_expression_formatter.rb
logstash-output-scalyr-0.1.24.beta vendor/bundle/jruby/2.5.0/gems/pry-0.10.4-java/lib/pry/commands/cat/input_expression_formatter.rb
logstash-output-scalyr-0.1.23.beta vendor/bundle/jruby/2.5.0/gems/pry-0.10.4-java/lib/pry/commands/cat/input_expression_formatter.rb
logstash-output-scalyr-0.1.22.beta vendor/bundle/jruby/2.5.0/gems/pry-0.10.4-java/lib/pry/commands/cat/input_expression_formatter.rb
logstash-output-scalyr-0.1.21.beta vendor/bundle/jruby/2.5.0/gems/pry-0.10.4-java/lib/pry/commands/cat/input_expression_formatter.rb
logstash-output-scalyr-0.1.20.beta vendor/bundle/jruby/2.5.0/gems/pry-0.10.4-java/lib/pry/commands/cat/input_expression_formatter.rb
logstash-output-scalyr-0.1.19.beta vendor/bundle/jruby/2.5.0/gems/pry-0.10.4-java/lib/pry/commands/cat/input_expression_formatter.rb
logstash-output-scalyr-0.1.18.beta vendor/bundle/jruby/2.5.0/gems/pry-0.10.4-java/lib/pry/commands/cat/input_expression_formatter.rb
logstash-output-scalyr-0.1.17.beta vendor/bundle/jruby/2.5.0/gems/pry-0.10.4-java/lib/pry/commands/cat/input_expression_formatter.rb
logstash-output-scalyr-0.1.16.beta vendor/bundle/jruby/2.5.0/gems/pry-0.10.4-java/lib/pry/commands/cat/input_expression_formatter.rb
logstash-output-scalyr-0.1.15.beta vendor/bundle/jruby/2.5.0/gems/pry-0.10.4-java/lib/pry/commands/cat/input_expression_formatter.rb
logstash-output-scalyr-0.1.14.beta vendor/bundle/jruby/2.5.0/gems/pry-0.10.4-java/lib/pry/commands/cat/input_expression_formatter.rb
logstash-output-scalyr-0.1.13 vendor/bundle/jruby/2.5.0/gems/pry-0.10.4-java/lib/pry/commands/cat/input_expression_formatter.rb
logstash-output-scalyr-0.1.12 vendor/bundle/jruby/2.5.0/gems/pry-0.10.4-java/lib/pry/commands/cat/input_expression_formatter.rb
logstash-output-scalyr-0.1.11.beta vendor/bundle/jruby/2.5.0/gems/pry-0.10.4-java/lib/pry/commands/cat/input_expression_formatter.rb
logstash-output-scalyr-0.1.10.beta vendor/bundle/jruby/2.5.0/gems/pry-0.10.4-java/lib/pry/commands/cat/input_expression_formatter.rb