Class: Cuboid::State

Inherits:
Object show all
Defined in:
lib/cuboid/state.rb,
lib/cuboid/state/options.rb,
lib/cuboid/state/application.rb

Overview

Stores and provides access to the state of the system.

Author:

Defined Under Namespace

Classes: Application, Error, Options

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.applicationFramework

Returns:

  • (Framework)


25
26
27
# File 'lib/cuboid/state.rb', line 25

def application
  @application
end

.optionsOptions

Returns:



22
23
24
# File 'lib/cuboid/state.rb', line 22

def options
  @options
end

Class Method Details

.clearObject

Clears all states.



69
70
71
72
# File 'lib/cuboid/state.rb', line 69

def clear
    each { |_, state| state.clear }
    self
end

.dump(directory) ⇒ String

Returns Location of the directory.

Parameters:

  • directory (String)

    Location of the dump directory.

Returns:

  • (String)

    Location of the directory.



45
46
47
48
49
50
51
52
53
# File 'lib/cuboid/state.rb', line 45

def dump( directory )
    FileUtils.mkdir_p( directory )

    each do |name, state|
        state.dump( "#{directory}/#{name}/" )
    end

    directory
end

.load(directory) ⇒ State

Returns ‘self`.

Parameters:

  • directory (String)

    Location of the dump directory.

Returns:



60
61
62
63
64
65
66
# File 'lib/cuboid/state.rb', line 60

def load( directory )
    each do |name, state|
        send( "#{name}=", state.class.load( "#{directory}/#{name}/" ) )
    end

    self
end

.resetObject



27
28
29
30
# File 'lib/cuboid/state.rb', line 27

def reset
    @options        = Options.new
    @application    = Application.new
end

.statisticsObject



32
33
34
35
36
37
38
# File 'lib/cuboid/state.rb', line 32

def statistics
    stats = {}
    each do |attribute|
        stats[attribute] = send(attribute).statistics
    end
    stats
end