lib/selfie/cursor.rb
def distance
      raise ArgumentError, "block required" unless block_given?

      beg_pos = position
      yield
      end_pos = position
      return unless end_pos && beg_pos

      # width, height
      [ end_pos[1] - beg_pos[1], end_pos[0] - beg_pos[0] ]
    end
# Calculates how many columns and rows the code in the given block moved the cursor
Calculates how many columns and rows the code in the given block moved the cursor
Calculates how many columns and rows the code in the given block moved the cursor
def distance
      raise ArgumentError, "block required" unless block_given?
      beg_pos = position
      yield
      end_pos = position
      return unless end_pos && beg_pos
      [ end_pos[1] - beg_pos[1], end_pos[0] - beg_pos[0] ]
    end
def distance raise ArgumentError , "block required" unless block_given? beg_pos = position yield end_pos = position return unless end_pos && beg_pos [ end_pos [ 1 ] - beg_pos [ 1 ] , end_pos [ 0 ] - beg_pos [ 0 ] ] end
Calculates how many columns and rows the code in the given block moved the cursor
Calculates how many columns and rows the code in the given block moved the cursor
# width, height