Class: Thread::Backtrace::PseudoLocation

Inherits:
Object
  • Object
show all
Defined in:
lib/pretty_debug.rb

Constant Summary collapse

Pattern =
/\A(?'f'[^:]+)(?::(?'l'\d+))?(?::in `(?'m'.+)'|(?'m'.+))?\z/m

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(to_s) ⇒ PseudoLocation

Returns a new instance of PseudoLocation.



72
73
74
75
76
77
78
# File 'lib/pretty_debug.rb', line 72

def initialize to_s
	@to_s = to_s
	m = @to_s.match(Pattern)
	@absolute_path, @lineno, @label = m[:f], m[:l] ? m[:l].to_i : nil, m[:m].to_s
	@path = File.basename(@absolute_path)
	@base_label = @label
end

Instance Attribute Details

#absolute_pathObject

Returns the value of attribute absolute_path.



71
72
73
# File 'lib/pretty_debug.rb', line 71

def absolute_path
  @absolute_path
end

#base_labelObject

Returns the value of attribute base_label.



71
72
73
# File 'lib/pretty_debug.rb', line 71

def base_label
  @base_label
end

#labelObject

Returns the value of attribute label.



71
72
73
# File 'lib/pretty_debug.rb', line 71

def label
  @label
end

#linenoObject

Returns the value of attribute lineno.



71
72
73
# File 'lib/pretty_debug.rb', line 71

def lineno
  @lineno
end

#pathObject

Returns the value of attribute path.



71
72
73
# File 'lib/pretty_debug.rb', line 71

def path
  @path
end

#to_sObject

Returns the value of attribute to_s.



71
72
73
# File 'lib/pretty_debug.rb', line 71

def to_s
  @to_s
end

Instance Method Details

#basenameObject



80
# File 'lib/pretty_debug.rb', line 80

def basename; File.basename(absolute_path) end

#dirnameObject



79
# File 'lib/pretty_debug.rb', line 79

def dirname; File.dirname(absolute_path) end

#realbasenameObject



88
# File 'lib/pretty_debug.rb', line 88

def realbasename; File.basename(realpath) end

#realdirnameObject



87
# File 'lib/pretty_debug.rb', line 87

def realdirname; File.dirname(realpath) end

#realpathObject



81
82
83
84
85
86
# File 'lib/pretty_debug.rb', line 81

def realpath
	case absolute_path
	when "-e".freeze, "(eval)".freeze then absolute_path
	else File.realpath(absolute_path) 
	end
end