Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

printing current line

  • Loading branch information...
commit 464e1a9968ffb800336ca3950a8ed7a911af34ed 1 parent 7fc02c9
@jugyo authored
Showing with 16 additions and 0 deletions.
  1. +16 −0 lib/ir_b.rb
View
16 lib/ir_b.rb
@@ -27,6 +27,22 @@ def self.start_session(binding)
module IrB
class << self
def -(_binding)
+ file = _binding.eval '__FILE__'
+ ir_b_line = _binding.eval '__LINE__'
+ puts "#{file}:#{ir_b_line} \e[90mtxmt://open/?url=file://#{ File.expand_path file }&line=#{ ir_b_line }\e[0m"
+
+ File.open(file).each_with_index do |line, index|
+ line_n = index + 1
+ next unless line_n > (ir_b_line - 6)
+ break if line_n > (ir_b_line + 5)
+ if line_n == ir_b_line
+ color = "\e[100m"
+ else
+ color = "\e[90m"
+ end
+ puts color + "#{line_n.to_s.rjust(5)}: #{line.strip} \e[0m"
+ end
+
IRB.start_session(_binding)
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.