Class: TempGenerator
- Inherits:
-
Object
- Object
- TempGenerator
- Defined in:
- lib/cosi-temp/temp-generator.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#file_array ⇒ Object
readonly
Returns the value of attribute file_array.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(date) ⇒ TempGenerator
constructor
A new instance of TempGenerator.
- #to_file ⇒ Object
Constructor Details
#initialize(date) ⇒ TempGenerator
Returns a new instance of TempGenerator.
4 5 6 |
# File 'lib/cosi-temp/temp-generator.rb', line 4 def initialize(date) @date = date end |
Instance Attribute Details
#date ⇒ Object (readonly)
Returns the value of attribute date.
2 3 4 |
# File 'lib/cosi-temp/temp-generator.rb', line 2 def date @date end |
#file_array ⇒ Object (readonly)
Returns the value of attribute file_array.
2 3 4 |
# File 'lib/cosi-temp/temp-generator.rb', line 2 def file_array @file_array end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
2 3 4 |
# File 'lib/cosi-temp/temp-generator.rb', line 2 def filename @filename end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
2 3 4 |
# File 'lib/cosi-temp/temp-generator.rb', line 2 def title @title end |
Instance Method Details
#to_file ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/cosi-temp/temp-generator.rb', line 8 def to_file if File.exist? @filename puts "The file already exists. Quitting" return end File.open(@filename, 'w') do |f| @file_array.each { |line| f.write line } end puts "File written to #{@filename}" end |