Class: PryMoves::Tools
- Inherits:
-
Object
- Object
- PryMoves::Tools
- Defined in:
- lib/pry-moves/tools.rb
Instance Method Summary collapse
- #add_breakpoint(var_name, line_number, binding) ⇒ Object
-
#initialize(pry) ⇒ Tools
constructor
A new instance of Tools.
Constructor Details
#initialize(pry) ⇒ Tools
Returns a new instance of Tools.
3 4 5 |
# File 'lib/pry-moves/tools.rb', line 3 def initialize pry @pry = pry end |
Instance Method Details
#add_breakpoint(var_name, line_number, binding) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/pry-moves/tools.rb', line 7 def add_breakpoint var_name, line_number, binding file, line = binding.eval('[__FILE__, __LINE__]') line_number ||= line lines = IO.readlines(file) value = binding.eval(var_name) value = value.to_json if value.is_a? String lines.insert line_number-1, "debug if #{var_name} == #{value}" File.open(file, 'w') do |file| file.puts lines end @pry.output.puts "🔴 Breakpoint added to #{File.basename file}:#{line_number}" end |