Class: Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/generatr/generator.rb

Constant Summary collapse

@@cabecera =
'"Date","ISBN","Amount"'
@@allBooks =
book1+"\n"+book2+"\n"+book3+"\n"+book4+"\n"

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#millionsObject

Returns the value of attribute millions.



4
5
6
# File 'lib/generatr/generator.rb', line 4

def millions
  @millions
end

Instance Method Details

#newFileObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/generatr/generator.rb', line 15

def newFile

    File.open( './file.csv', 'a' ) { |row| row.write @@cabecera+"\n" }

    nRepeticiones = 1_000_000 * @millions.to_i / 4

    nRepeticiones.times {

        File.open( './file.csv', 'a' ) { |row| row.write @@allBooks }
    
    }

    true # <~ only valid for Rspec
    
end