Class: Pry::Command::Cat::AbstractFormatter

Inherits:
Object
  • Object
show all
Includes:
Helpers::BaseHelpers, Helpers::CommandHelpers
Defined in:
lib/pry/commands/cat/abstract_formatter.rb

Instance Method Summary collapse

Methods included from Helpers::BaseHelpers

#colorize_code, #command_dependencies_met?, #find_command, #heading, #highlight, #not_a_real_file?, #safe_send, #silence_warnings, #stagger_output, #use_ansi_codes?

Methods included from Platform

#jruby?, #jruby_19?, #known_engines, #linux?, #mac_osx?, #mri?, #mri_19?, #mri_2?, #rbx?, #windows?, #windows_ansi?

Methods included from Helpers::CommandHelpers

#absolute_index_number, absolute_index_number, absolute_index_range, #absolute_index_range, command_error, #command_error, #get_method_or_raise, get_method_or_raise, internal_binding?, #internal_binding?, one_index_number, #one_index_number, one_index_range, #one_index_range, #one_index_range_or_number, one_index_range_or_number, #restrict_to_lines, restrict_to_lines, #set_file_and_dir_locals, set_file_and_dir_locals, #temp_file, temp_file, #unindent, unindent

Methods included from Helpers::OptionsHelpers

method_object, #method_object, method_options, #method_options

Instance Method Details

#between_linesObject (private)


22
23
24
# File 'lib/pry/commands/cat/abstract_formatter.rb', line 22

def between_lines
  [opts[:start] || 1, opts[:end] || -1]
end

#code_typeObject (private)


14
15
16
# File 'lib/pry/commands/cat/abstract_formatter.rb', line 14

def code_type
  opts[:type] || :ruby
end

#decorate(content) ⇒ Object (private)


8
9
10
11
12
# File 'lib/pry/commands/cat/abstract_formatter.rb', line 8

def decorate(content)
  content.code_type = code_type
  content.between(*between_lines).
    with_line_numbers(use_line_numbers?).highlighted
end

#use_line_numbers?Boolean (private)


18
19
20
# File 'lib/pry/commands/cat/abstract_formatter.rb', line 18

def use_line_numbers?
  opts.present?(:'line-numbers') || opts.present?(:ex)
end