Class: RCheck::Backtrace::Line
- Inherits:
-
Object
- Object
- RCheck::Backtrace::Line
- Defined in:
- lib/rcheck/backtrace.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#line ⇒ Object
readonly
Returns the value of attribute line.
Instance Method Summary collapse
-
#initialize(str) ⇒ Line
constructor
A new instance of Line.
- #scope ⇒ Object
- #short ⇒ Object
- #source ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(str) ⇒ Line
Returns a new instance of Line.
14 15 16 17 18 19 |
# File 'lib/rcheck/backtrace.rb', line 14 def initialize(str) @file, @line, @scope = str.split(':') @line = line.to_i @file = Pathname.new(File.(file)). relative_path_from Pathname.new(Dir.pwd) end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
13 14 15 |
# File 'lib/rcheck/backtrace.rb', line 13 def file @file end |
#line ⇒ Object (readonly)
Returns the value of attribute line.
13 14 15 |
# File 'lib/rcheck/backtrace.rb', line 13 def line @line end |
Instance Method Details
#scope ⇒ Object
25 26 27 |
# File 'lib/rcheck/backtrace.rb', line 25 def scope @scope[4..-2] end |
#short ⇒ Object
21 22 23 |
# File 'lib/rcheck/backtrace.rb', line 21 def short "#{@file}:#{@line}" end |
#source ⇒ Object
33 34 35 36 |
# File 'lib/rcheck/backtrace.rb', line 33 def source src = File.readlines(File.(@file))[@line-1] src && src.strip end |
#to_s ⇒ Object
29 30 31 |
# File 'lib/rcheck/backtrace.rb', line 29 def to_s "%-30s %s" % [short, scope] end |