Class: PowerTrace::Entry
- Inherits:
-
Object
- Object
- PowerTrace::Entry
- Includes:
- ColorizeHelper
- Defined in:
- lib/power_trace/entry.rb
Constant Summary collapse
- UNDEFINED =
"[undefined]"
- EMPTY_STRING =
""
- EMPTY_ARRAY =
[].freeze
- EMPTY_HASH =
{}.freeze
- SET_IVAR_INSTRUCTION_REGEX =
/setinstancevariable/
- SPACE =
"\s"
- DEFAULT_LINE_LIMIT =
100
- ATTRIBUTE_COLORS =
{ name: :blue, location: :green, arguments_string: :orange, locals_string: :megenta, ivars_string: :cyan }
Constants included from ColorizeHelper
ColorizeHelper::COLOR_CODES, ColorizeHelper::RESET_MARK
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#filepath ⇒ Object
readonly
Returns the value of attribute filepath.
-
#frame ⇒ Object
readonly
Returns the value of attribute frame.
-
#ivars ⇒ Object
readonly
Returns the value of attribute ivars.
-
#line_number ⇒ Object
readonly
Returns the value of attribute line_number.
-
#locals ⇒ Object
readonly
Returns the value of attribute locals.
-
#receiver ⇒ Object
readonly
Returns the value of attribute receiver.
Instance Method Summary collapse
- #arguments_string(options = {}) ⇒ Object
- #call_trace(options = {}) ⇒ Object
-
#initialize(frame) ⇒ Entry
constructor
A new instance of Entry.
- #ivars_string(options = {}) ⇒ Object
- #locals_string(options = {}) ⇒ Object
- #location(options = {}) ⇒ Object
- #name(options = {}) ⇒ Object
- #to_s(options = {}) ⇒ Object
Constructor Details
#initialize(frame) ⇒ Entry
Returns a new instance of Entry.
17 18 19 20 21 22 23 |
# File 'lib/power_trace/entry.rb', line 17 def initialize(frame) @frame = frame @filepath, @line_number = frame.source_location @receiver = frame.receiver @locals, @arguments = collect_locals_and_arguments @ivars = collect_ivars end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
15 16 17 |
# File 'lib/power_trace/entry.rb', line 15 def arguments @arguments end |
#filepath ⇒ Object (readonly)
Returns the value of attribute filepath.
15 16 17 |
# File 'lib/power_trace/entry.rb', line 15 def filepath @filepath end |
#frame ⇒ Object (readonly)
Returns the value of attribute frame.
15 16 17 |
# File 'lib/power_trace/entry.rb', line 15 def frame @frame end |
#ivars ⇒ Object (readonly)
Returns the value of attribute ivars.
15 16 17 |
# File 'lib/power_trace/entry.rb', line 15 def ivars @ivars end |
#line_number ⇒ Object (readonly)
Returns the value of attribute line_number.
15 16 17 |
# File 'lib/power_trace/entry.rb', line 15 def line_number @line_number end |
#locals ⇒ Object (readonly)
Returns the value of attribute locals.
15 16 17 |
# File 'lib/power_trace/entry.rb', line 15 def locals @locals end |
#receiver ⇒ Object (readonly)
Returns the value of attribute receiver.
15 16 17 |
# File 'lib/power_trace/entry.rb', line 15 def receiver @receiver end |
Instance Method Details
#arguments_string(options = {}) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/power_trace/entry.rb', line 33 def arguments_string( = {}) <<~STR.chomp #{[:indentation]}(Arguments) #{hash_to_string(arguments, false, )} STR end |
#call_trace(options = {}) ⇒ Object
54 55 56 |
# File 'lib/power_trace/entry.rb', line 54 def call_trace( = {}) "#{location()}:in `#{name()}'" end |
#ivars_string(options = {}) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/power_trace/entry.rb', line 47 def ivars_string( = {}) <<~STR.chomp #{[:indentation]}(Instance Variables) #{hash_to_string(ivars, false, )} STR end |
#locals_string(options = {}) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/power_trace/entry.rb', line 40 def locals_string( = {}) <<~STR.chomp #{[:indentation]}(Locals) #{hash_to_string(locals, false, )} STR end |
#location(options = {}) ⇒ Object
29 30 31 |
# File 'lib/power_trace/entry.rb', line 29 def location( = {}) "#{filepath}:#{line_number}" end |
#name(options = {}) ⇒ Object
25 26 27 |
# File 'lib/power_trace/entry.rb', line 25 def name( = {}) frame.frame_description end |
#to_s(options = {}) ⇒ Object
81 82 83 84 85 |
# File 'lib/power_trace/entry.rb', line 81 def to_s( = {}) # this is to prevent entries from polluting each other's options # of course, that'd only happen if I did something stupid ;) assemble_string(.dup) end |