Class: OlHelper

Inherits:
Object show all
Defined in:
lib/xiki/ol_helper.rb

Class Method Summary collapse

Class Method Details

.launch ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/xiki/ol_helper.rb', line 20

def self.launch
  prefix = Keys.prefix :clear=>1

  # Get path from end
  path = Ol.file_path #[/\/.+/]

  # TODO: get total_lines - current_line
  distance_to_end = Line.number(View.bottom) - Line.number

  # Go to log.lines and get n from end
  arr = IO.readlines("#{path}.lines")
  line = arr[- distance_to_end]

  path, line = line.split(':')

  View.open path
  View.to_line line.to_i

  if prefix == 0
    View.layout_output
    Line.next
  end
end

.source_to_output(file, line) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/xiki/ol_helper.rb', line 2

def self.source_to_output file, line

  target = "#{file}:#{line}\n"

  lines = IO.readlines("/tmp/output_ol.notes.lines").reverse

  lines_total = lines.length

  # Get how far from bottom
  distance, found = 0, nil
  while distance < lines_total do
    break found = distance if lines[distance] == target
    distance += 1
  end

  found
end