Class: Readfile

Inherits:
Object
  • Object
show all
Defined in:
lib/fake_csv/readfile.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeReadfile

Returns a new instance of Readfile.



6
7
8
# File 'lib/fake_csv/readfile.rb', line 6

def initialize
    @format = Hash.new
end

Instance Attribute Details

#formatObject

Returns the value of attribute format.



5
6
7
# File 'lib/fake_csv/readfile.rb', line 5

def format
  @format
end

#headerObject

Returns the value of attribute header.



5
6
7
# File 'lib/fake_csv/readfile.rb', line 5

def header
  @header
end

#timeObject

Returns the value of attribute time.



5
6
7
# File 'lib/fake_csv/readfile.rb', line 5

def time
  @time
end

Instance Method Details

#read(file) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/fake_csv/readfile.rb', line 9

def read(file)
    index = 0
    File.foreach(file) do |row|
        sep = row.split(":")

        if sep[0] == "header"
            @header = sep[1].chomp
        elsif sep[0] =~ /format/i
            @format.store(index, :format=>sep[0], :content=>sep[1].chomp)
            index += 1
        end
    end
end