Class: Ergo::System

Inherits:
Book
  • Object
show all
Defined in:
lib/ergo/system.rb

Overview

A system stores defined states and rules and books, which are subsystems.

Instance Attribute Summary collapse

Attributes inherited from Book

#name, #rules, #scripts, #session, #states

Instance Method Summary collapse

Methods inherited from Book

#clear_rule_options, #desc, #env, #file, #get_rule_options, #ignore, #ignore!, #import, #mark, #notify, #private, #rule, #state, #state?

Constructor Details

#initialize(script = nil, options = {}) ⇒ System

Initialize new System instance.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/ergo/system.rb', line 17

def initialize(script=nil, options={})
  extend self
  extend ShellUtils

  @ignore  = options[:ignore] || Ignore.new
  @session = OpenStruct.new

  @scripts = []
  @rules   = []
  @states  = {}
  @books   = {}
  @digests = {}

  import script if script
end

Instance Attribute Details

#booksHash (readonly)

Map of books by name.

Returns:

  • (Hash)

    Returns



36
37
38
# File 'lib/ergo/system.rb', line 36

def books
  @books
end

Instance Method Details

#book(name, &block) ⇒ Book

Books are stored with rules to preserve order of application.

Returns:



41
42
43
44
45
46
47
# File 'lib/ergo/system.rb', line 41

def book(name, &block)
  @books[name.to_s] ||= (
    book = Book.new(self, name, &block)
    @rules << book
    book
  )
end