Class: RubySnooper::TraceWriter::Return

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_snooper/trace_writer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method_id, event, number, time, code, return_value, file_path) ⇒ Return

Returns a new instance of Return.



114
115
116
117
118
119
120
121
122
# File 'lib/ruby_snooper/trace_writer.rb', line 114

def initialize(method_id, event, number, time, code, return_value, file_path)
  @method_id = method_id
  @event = event
  @number = number
  @time = time
  @code = code
  @return_value = return_value
  @file_path = file_path
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



112
113
114
# File 'lib/ruby_snooper/trace_writer.rb', line 112

def code
  @code
end

#eventObject (readonly)

Returns the value of attribute event.



112
113
114
# File 'lib/ruby_snooper/trace_writer.rb', line 112

def event
  @event
end

#method_idObject (readonly)

Returns the value of attribute method_id.



112
113
114
# File 'lib/ruby_snooper/trace_writer.rb', line 112

def method_id
  @method_id
end

#numberObject (readonly)

Returns the value of attribute number.



112
113
114
# File 'lib/ruby_snooper/trace_writer.rb', line 112

def number
  @number
end

#return_valueObject (readonly)

Returns the value of attribute return_value.



112
113
114
# File 'lib/ruby_snooper/trace_writer.rb', line 112

def return_value
  @return_value
end

#timeObject (readonly)

Returns the value of attribute time.



112
113
114
# File 'lib/ruby_snooper/trace_writer.rb', line 112

def time
  @time
end

Instance Method Details

#code_colorized(str) ⇒ Object



129
130
131
# File 'lib/ruby_snooper/trace_writer.rb', line 129

def code_colorized(str)
  ::CodeRay.scan(str, :ruby).term
end

#colorized(str) ⇒ Object



133
134
135
# File 'lib/ruby_snooper/trace_writer.rb', line 133

def colorized(str)
  "\e[0;31m#{str}\e[0m"
end


124
125
126
127
# File 'lib/ruby_snooper/trace_writer.rb', line 124

def print
  STDERR.puts "#{Time.now.strftime("%T,%L")} #{@event} #{@number.to_s.rjust(4)} #{code_colorized(@code)}"
  STDERR.puts colorized("Return value #{@return_value}")
end