class Pry::Code::LOC
loc.line #=> “ def examplen :examplenend”
loc.indent(3)
#=> nil
end
:example
def example
puts loc.line
loc = LOC.new(“def examplen :examplenend”, 1)
@example
@api private
this class.
parameter) can be changed via instance methods. ‘Pry::Code` heavily uses
line and a line number. A `LOC` object’s state (namely, the line
Represents a line of code. A line of code is a tuple, which consists of a
def ==(other)
-
(Boolean)
-
def ==(other) other.tuple == tuple end
def add_line_number(max_width = 0)
-
(void)
-
Parameters:
-
max_width
(Integer
) --
def add_line_number(max_width = 0) padded = lineno.to_s.rjust(max_width) colorized_lineno = Pry::Helpers::BaseHelpers.colorize_code(padded) tuple[0] = "#{ colorized_lineno }: #{ line }" end
def add_marker(marker_lineno)
-
(void)
-
Parameters:
-
marker_lineno
(Integer
) -- If it is equal to the `lineno`, then
def add_marker(marker_lineno) tuple[0] = if lineno == marker_lineno " => #{ line }" else " #{ line }" end end
def colorize(code_type)
-
(void)
-
Parameters:
-
code_type
(Symbol
) --
def colorize(code_type) tuple[0] = CodeRay.scan(line, code_type).term end
def dup
def dup self.class.new(line, lineno) end
def indent(distance)
-
(void)
-
Parameters:
-
distance
(Integer
) --
def indent(distance) tuple[0] = "#{ ' ' * distance }#{ line }" end
def initialize(line, lineno)
-
lineno
(Integer
) -- The position of the +line+. -
line
(String
) -- The line of code.
def initialize(line, lineno) @tuple = [line.chomp, lineno.to_i] end
def line
-
(String)
-
def line tuple.first end
def lineno
-
(Integer)
-
def lineno tuple.last end