Class: Bookfile::Builder

Inherits:
Object
  • Object
show all
Includes:
LogUtils::Logging
Defined in:
lib/bookfile/builder.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBuilder

Returns a new instance of Builder.



24
25
26
27
# File 'lib/bookfile/builder.rb', line 24

def initialize
  puts "starting new bookfile; lets go"
  @bookfile = Bookfile.new
end

Instance Attribute Details

#bookfileObject (readonly)

Returns the value of attribute bookfile.



22
23
24
# File 'lib/bookfile/builder.rb', line 22

def bookfile
  @bookfile
end

Class Method Details

.load(code) ⇒ Object



15
16
17
18
19
# File 'lib/bookfile/builder.rb', line 15

def self.load( code )
  builder = Builder.new
  builder.instance_eval( code )
  builder
end

.load_file(path) ⇒ Object



10
11
12
13
# File 'lib/bookfile/builder.rb', line 10

def self.load_file( path )
  code = File.read_utf8( path )
  self.load( code )
end

Instance Method Details

#beer(opts = {}) ⇒ Object



42
43
44
45
46
# File 'lib/bookfile/builder.rb', line 42

def beer( opts={} )
  puts "beer opts: #{opts.inspect}"
  ## todo: to avoid name class use BeerDef, WorldDef ?? etc.
  @bookfile.databases << BeerDef.new( opts )
end

#book(opts = {}, &block) ⇒ Object



55
56
57
58
# File 'lib/bookfile/builder.rb', line 55

def book( opts={}, &block )
  puts "book opts: #{opts.inspect}"
  @bookfile.books << BookDef.new( opts, block )
end

#football(opts = {}) ⇒ Object



48
49
50
51
# File 'lib/bookfile/builder.rb', line 48

def football( opts={} )
  puts "football opts: #{opts.inspect}"
  @bookfile.databases << FootballDef.new( opts )
end

#package(name, opts = {}) ⇒ Object



30
31
32
33
# File 'lib/bookfile/builder.rb', line 30

def package( name, opts={} )
  puts "package '#{name}'"
  @bookfile.packages << BookPackage.new( name, opts )
end

#world(opts = {}) ⇒ Object

database options



37
38
39
40
# File 'lib/bookfile/builder.rb', line 37

def world( opts={} )
  puts "world opts: #{opts.inspect}"
  @bookfile.databases << WorldDef.new( opts )
end