Class: RbTags::File

Inherits:
Object show all
Defined in:
lib/rbtags/file.rb

Instance Method Summary collapse

Constructor Details

#initialize(file, line) ⇒ File

Returns a new instance of File.



4
5
6
# File 'lib/rbtags/file.rb', line 4

def initialize(file, line)
  @file, @line = file, Integer(line)
end

Instance Method Details

#lineObject



13
14
15
16
17
18
19
# File 'lib/rbtags/file.rb', line 13

def line
  @@lines ||= Hash.new{ |lines, file|
    sum = 0
    lines[file] = File.open(file, 'rb'){ |io| io.map{ |line| line.chomp } }
  }
  @@lines[@file][@line - 1]
end

#nameObject



8
9
10
11
# File 'lib/rbtags/file.rb', line 8

def name
  @@expanded ||= Hash.new{ |files, file| files[file] = File.expand_path(file) }
  @@expanded[@file]
end