Class Pry::Code::LOC
In: lib/pry/code/loc.rb
Parent: Object

Represents a line of code. A line of code is a tuple, which consists of a line and a line number. A `LOC` object‘s state (namely, the line parameter) can be changed via instance methods. `Pry::Code` heavily uses this class.

@api private @example

  loc = LOC.new("def example\n  :example\nend", 1)
  puts loc.line
  def example
    :example
  end
  #=> nil

  loc.indent(3)
  loc.line #=> "   def example\n  :example\nend"

Methods

==   add_line_number   add_marker   colorize   dup   indent   line   lineno   new  

Attributes

tuple  [R]  @return [Array<String, Integer>]

Public Class methods

@param [String] line The line of code. @param [Integer] lineno The position of the line.

Public Instance methods

@return [Boolean]

Prepends the line number `lineno` to the `line`.

@param [Integer] max_width @return [void]

Prepends a marker "=>" or an empty marker to the line.

@param [Integer] marker_lineno If it is equal to the `lineno`, then

  prepend a hashrocket. Otherwise, an empty marker.

@return [void]

Paints the `line` of code.

@param [Symbol] code_type @return [void]

Indents the `line` with distance spaces.

@param [Integer] distance @return [void]

@return [String]

@return [Integer]

[Validate]