Class: Declare::CallerEntry
- Inherits:
-
Struct
- Object
- Struct
- Declare::CallerEntry
- Defined in:
- lib/declare/callerentry.rb
Instance Attribute Summary collapse
-
#block_level ⇒ Object
Returns the value of attribute block_level.
-
#file_name ⇒ Object
Returns the value of attribute file_name.
-
#line_number ⇒ Object
Returns the value of attribute line_number.
-
#method_name ⇒ Object
Returns the value of attribute method_name.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#block_level ⇒ Object
Returns the value of attribute block_level
5 6 7 |
# File 'lib/declare/callerentry.rb', line 5 def block_level @block_level end |
#file_name ⇒ Object
Returns the value of attribute file_name
5 6 7 |
# File 'lib/declare/callerentry.rb', line 5 def file_name @file_name end |
#line_number ⇒ Object
Returns the value of attribute line_number
5 6 7 |
# File 'lib/declare/callerentry.rb', line 5 def line_number @line_number end |
#method_name ⇒ Object
Returns the value of attribute method_name
5 6 7 |
# File 'lib/declare/callerentry.rb', line 5 def method_name @method_name end |
Class Method Details
.parse(caller_entry) ⇒ CallerEntry
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/declare/callerentry.rb', line 9 def parse(caller_entry) matched = /\A(?<file_name>.+?):(?<line_number>\d+)(?::in `(?<method_name>.*)')?/.match(caller_entry) if matched block_level = case matched[:method_name] when /block \((\d+) levels\)/ Regexp.last_match(1).to_i when /block/ 1 else 0 end new(file_name: matched[:file_name], line_number: Integer(matched[:line_number]), method_name: matched[:method_name], block_level:) else raise TypeError, caller_entry end end |
Instance Method Details
#to_s ⇒ String
29 30 31 |
# File 'lib/declare/callerentry.rb', line 29 def to_s "#{file_name}:#{line_number}" end |