Class: TempGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/cosi-temp/temp-generator.rb

Direct Known Subclasses

MeetingsGenerator, ProjectsGenerator

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#dateObject (readonly)

Returns the value of attribute date.



2
3
4
# File 'lib/cosi-temp/temp-generator.rb', line 2

def date
  @date
end

#file_arrayObject (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

#filenameObject (readonly)

Returns the value of attribute filename.



2
3
4
# File 'lib/cosi-temp/temp-generator.rb', line 2

def filename
  @filename
end

#titleObject (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_fileObject



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