Class: Logue::Frame
- Inherits:
-
Object
- Object
- Logue::Frame
- Defined in:
- lib/logue/frame.rb
Constant Summary collapse
- FRAME_RE =
Regexp.new '(.*):(\d+)(?::in \`(.*)\')?'
Instance Attribute Summary collapse
-
#line ⇒ Object
readonly
Returns the value of attribute line.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #formatted(format, cname) ⇒ Object
-
#initialize(entry: nil, path: nil, line: nil, method: nil) ⇒ Frame
constructor
A new instance of Frame.
- #to_s ⇒ Object
Constructor Details
#initialize(entry: nil, path: nil, line: nil, method: nil) ⇒ Frame
Returns a new instance of Frame.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/logue/frame.rb', line 14 def initialize entry: nil, path: nil, line: nil, method: nil # entry if called from "caller(x)" elements, path/line/method if called from # "caller_location(x)" elements. if entry md = FRAME_RE.match entry @path = md[1] @line = md[2].to_i @method = md[3] || "" else @path = path @line = line @method = method end end |
Instance Attribute Details
#line ⇒ Object (readonly)
Returns the value of attribute line.
11 12 13 |
# File 'lib/logue/frame.rb', line 11 def line @line end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
12 13 14 |
# File 'lib/logue/frame.rb', line 12 def method @method end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
10 11 12 |
# File 'lib/logue/frame.rb', line 10 def path @path end |
Instance Method Details
#formatted(format, cname) ⇒ Object
33 34 35 |
# File 'lib/logue/frame.rb', line 33 def formatted format, cname format.format @path, @line, cname, @method end |
#to_s ⇒ Object
29 30 31 |
# File 'lib/logue/frame.rb', line 29 def to_s [ :path, :line, :method ].collect { |field| "#{field}: " + send(field).to_s }.join ", " end |