Class: Bookfile::Builder
- Inherits:
-
Object
- Object
- Bookfile::Builder
- Includes:
- LogUtils::Logging
- Defined in:
- lib/bookfile/builder.rb
Instance Attribute Summary collapse
-
#bookfile ⇒ Object
readonly
Returns the value of attribute bookfile.
Class Method Summary collapse
Instance Method Summary collapse
- #beer(opts = {}) ⇒ Object
- #book(opts = {}, &block) ⇒ Object
- #football(opts = {}) ⇒ Object
-
#initialize ⇒ Builder
constructor
A new instance of Builder.
- #package(name, opts = {}) ⇒ Object
-
#world(opts = {}) ⇒ Object
database options.
Constructor Details
Instance Attribute Details
#bookfile ⇒ Object (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 |