Class: PryDebug::LineBreakpoint

Inherits:
Struct
  • Object
show all
Includes:
ConditionalBreakpoint
Defined in:
lib/pry_debug/line_breakpoint.rb

Instance Attribute Summary collapse

Attributes included from ConditionalBreakpoint

#condition

Instance Method Summary collapse

Instance Attribute Details

#fileObject

Returns the value of attribute file

Returns:

  • (Object)

    the current value of file



2
3
4
# File 'lib/pry_debug/line_breakpoint.rb', line 2

def file
  @file
end

#idObject

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



2
3
4
# File 'lib/pry_debug/line_breakpoint.rb', line 2

def id
  @id
end

#lineObject

Returns the value of attribute line

Returns:

  • (Object)

    the current value of line



2
3
4
# File 'lib/pry_debug/line_breakpoint.rb', line 2

def line
  @line
end

Instance Method Details

#at_location?(other_file, other_line) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
8
9
10
11
12
13
# File 'lib/pry_debug/line_breakpoint.rb', line 5

def at_location?(other_file, other_line)
  return false unless line == other_line

  path = ""
  split_file(other_file).any? do |part|
    path = File.join(part, path).chomp('/')
    path == file
  end
end

#is_at?(other_file, other_line, binding) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/pry_debug/line_breakpoint.rb', line 15

def is_at?(other_file, other_line, binding)
  at_location?(other_file, other_line) && super(binding)
end

#split_file(file) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/pry_debug/line_breakpoint.rb', line 19

def split_file(file)
  ary = []

  loop do
    dirname, filename = File.split(file)

    ary << filename

    if dirname == '.'
      break
    elsif dirname == '/'
      ary << '/'
      break
    else
      file = dirname
    end
  end

  ary
end

#to_sObject



40
41
42
# File 'lib/pry_debug/line_breakpoint.rb', line 40

def to_s
  "breakpoint #{id} at #{file}:#{line}#{super}"
end