Class: GetFilePath

Inherits:
Object
  • Object
show all
Defined in:
lib/qiita_org/get_file_path.rb

Instance Method Summary collapse

Constructor Details

#initialize(src) ⇒ GetFilePath



2
3
4
# File 'lib/qiita_org/get_file_path.rb', line 2

def initialize(src)
  @src = src
end

Instance Method Details

#get_file_pathObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/qiita_org/get_file_path.rb', line 6

def get_file_path()
  #lines = File.readlines(@src.gsub(".org", ".md"))
  lines = File.readlines(@src)
  files = []
  lines.each do |line|
    #if path2 = line.match(/\!\[img\]\(((.+))/)# "(.+)"\)/)
    #if path2 = line.match(/\[\[file\:(.+)\](.+)\]\]/) || line.match(/\[\[file:(.+)\]\]/)
    if path2 = line.match(/\[\[(.+)\]\[file:(.+)\]\]/) || line.match(/\[\[file:(.+)\]\]/)
      if path2[2] == nil
        files << path2[1]
      else
        files << path2[2]
      end
    end
  end

  #paths = []
  #files.each do |file|
    #paths << File.join(Dir.pwd, file)
  #end
  #return paths
  return files
end