Class: LetItGo::CallerLine
- Inherits:
-
Object
- Object
- LetItGo::CallerLine
- Defined in:
- lib/let_it_go/caller_line.rb
Overview
Given a single line from ‘caller` retrieves line_number, file_name and can read the contents of the file
Instance Attribute Summary collapse
-
#file_name ⇒ Object
Returns the value of attribute file_name.
-
#line_number ⇒ Object
Returns the value of attribute line_number.
Instance Method Summary collapse
- #contents ⇒ Object
-
#initialize(string) ⇒ CallerLine
constructor
A new instance of CallerLine.
Constructor Details
#initialize(string) ⇒ CallerLine
6 7 8 9 10 11 12 |
# File 'lib/let_it_go/caller_line.rb', line 6 def initialize(string) file_line = string.split(":in `".freeze).first file_line_array = file_line.split(":".freeze) @line_number = file_line_array.pop @file_name = file_line_array.join(":".freeze) # name may have `:` in it end |
Instance Attribute Details
#file_name ⇒ Object
Returns the value of attribute file_name.
5 6 7 |
# File 'lib/let_it_go/caller_line.rb', line 5 def file_name @file_name end |
#line_number ⇒ Object
Returns the value of attribute line_number.
5 6 7 |
# File 'lib/let_it_go/caller_line.rb', line 5 def line_number @line_number end |
Instance Method Details
#contents ⇒ Object
14 15 16 |
# File 'lib/let_it_go/caller_line.rb', line 14 def contents @contents ||= read || "" end |