Method: Ld::Document#initialize

Defined in:
lib/ld/document/document.rb

#initialize(file) ⇒ Document

作用 读一个rb文件生成api数据



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/ld/document/document.rb', line 6

def initialize file
  @doc = {}
  @lines = file.lines
  @lines.each_with_index do |line, i|
    arr = line.split(' ')
    if arr.delete_at(0) == 'def'
      notes = get_notes(@lines, i)
      if notes.size > 0
        method = arr.delete_at(0)
        @doc[method] = {
            params:arr.join(' '),
            notes:notes
        }
      end
    end
  end
end