Class: AutoPilot::ResultsFile

Inherits:
Object
  • Object
show all
Defined in:
lib/auto_pilot/files.rb

Overview

File where the posted results for a suite are written. The file’s name is written as suite_name_year.month.day_hour.minute.second.html

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dir, suite_name, data) ⇒ ResultsFile

Returns a new instance of ResultsFile.



45
46
47
48
49
# File 'lib/auto_pilot/files.rb', line 45

def initialize(dir, suite_name, data)
  @dir = dir
  @suite_name = suite_name
  @data = data
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



43
44
45
# File 'lib/auto_pilot/files.rb', line 43

def data
  @data
end

#dirObject (readonly)

Returns the value of attribute dir.



43
44
45
# File 'lib/auto_pilot/files.rb', line 43

def dir
  @dir
end

#suite_nameObject (readonly)

Returns the value of attribute suite_name.



43
44
45
# File 'lib/auto_pilot/files.rb', line 43

def suite_name
  @suite_name
end

Instance Method Details

#pathObject



56
57
58
59
60
# File 'lib/auto_pilot/files.rb', line 56

def path
  time = Time.now
  time_stamp = time.strftime("%Y.%m.%d_%I.%M.%S%p")
  @dir + File::SEPARATOR + @suite_name.delete(" ") +"_" + time_stamp + ".html"
end

#writeObject



51
52
53
54
# File 'lib/auto_pilot/files.rb', line 51

def write
  FileUtils.mkdir(@dir) unless File.exist?(@dir)
  File.open(path, 'w'){|out| out.write @data}
end