Class: Readfile
- Inherits:
-
Object
- Object
- Readfile
- Defined in:
- lib/fake_csv/readfile.rb
Instance Attribute Summary collapse
-
#format ⇒ Object
Returns the value of attribute format.
-
#header ⇒ Object
Returns the value of attribute header.
-
#time ⇒ Object
Returns the value of attribute time.
Instance Method Summary collapse
-
#initialize ⇒ Readfile
constructor
A new instance of Readfile.
- #read(file) ⇒ Object
Constructor Details
#initialize ⇒ Readfile
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
#format ⇒ Object
Returns the value of attribute format.
5 6 7 |
# File 'lib/fake_csv/readfile.rb', line 5 def format @format end |
#header ⇒ Object
Returns the value of attribute header.
5 6 7 |
# File 'lib/fake_csv/readfile.rb', line 5 def header @header end |
#time ⇒ Object
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 |