Class: SeedFu::Writer::Abstract
- Inherits:
-
Object
- Object
- SeedFu::Writer::Abstract
- Defined in:
- lib/seed-fu/writer/abstract.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#number_of_seeds ⇒ Object
Returns the value of attribute number_of_seeds.
-
#seed_handle ⇒ Object
Returns the value of attribute seed_handle.
Instance Method Summary collapse
- #add_seed(hash) ⇒ Object
- #finish ⇒ Object
- #footer ⇒ Object
- #header ⇒ Object
-
#initialize(options = {}) ⇒ Abstract
constructor
A new instance of Abstract.
- #write_footer ⇒ Object
- #write_header ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Abstract
Returns a new instance of Abstract.
8 9 10 11 12 13 14 15 |
# File 'lib/seed-fu/writer/abstract.rb', line 8 def initialize(={}) self.config = self.number_of_seeds = 0 self.seed_handle = File.new(self.config[:seed_file], 'w') write_header end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
6 7 8 |
# File 'lib/seed-fu/writer/abstract.rb', line 6 def config @config end |
#number_of_seeds ⇒ Object
Returns the value of attribute number_of_seeds.
6 7 8 |
# File 'lib/seed-fu/writer/abstract.rb', line 6 def number_of_seeds @number_of_seeds end |
#seed_handle ⇒ Object
Returns the value of attribute seed_handle.
6 7 8 |
# File 'lib/seed-fu/writer/abstract.rb', line 6 def seed_handle @seed_handle end |
Instance Method Details
#add_seed(hash) ⇒ Object
36 37 38 39 |
# File 'lib/seed-fu/writer/abstract.rb', line 36 def add_seed(hash) $stdout.puts "Added #{hash.inspect}" unless config[:quiet] self.number_of_seeds += 1 end |
#finish ⇒ Object
49 50 51 52 |
# File 'lib/seed-fu/writer/abstract.rb', line 49 def finish seed_handle.close end |
#footer ⇒ Object
30 31 32 33 34 |
# File 'lib/seed-fu/writer/abstract.rb', line 30 def <<-END # End auto-generated file. END end |
#header ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/seed-fu/writer/abstract.rb', line 17 def header <<-END # DO NOT MODIFY THIS FILE, it was auto-generated. # # Date: #{DateTime.now} # Using #{self.class} to seed #{config[:seed_model]} # Written with the command: # # #{$0} #{$*.join} # END end |
#write_footer ⇒ Object
45 46 47 |
# File 'lib/seed-fu/writer/abstract.rb', line 45 def seed_handle.syswrite end |
#write_header ⇒ Object
41 42 43 |
# File 'lib/seed-fu/writer/abstract.rb', line 41 def write_header seed_handle.syswrite header end |