Module: VarParser

Defined in:
lib/var_parser.rb,
lib/var_parser/version.rb

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.extract_instance_vars(filepath) ⇒ Object



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

def self.extract_instance_vars(filepath)    
  puts 'Starting Extraction from file ........'+ARGF.filename
  vars = []
  File.open(filepath, "r") do |f|
    f.each_line do |line|
      x=-1
      print '..'
      (0...line.size).each do |ch|
        break if line[ch] == '#'
        if x == -1 && line[ch] == '@'
          x = ch
          next
        end
        if  /[A-Za-z0-9_]/.match(line[ch]).nil?  && x!=-1
          vars.push(line[x...ch])
          x = -1
        end #if @
      end #ch each
    end # each_line
  end
  puts ''
  puts  'Extraction complete'
  puts vars.uniq.inspect
  return vars
end