Class: Cuboid::Data

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

Overview

Stores and provides access to the data of the system.

Author:

Defined Under Namespace

Classes: Application, Error

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.applicationFramework

Returns:

  • (Framework)


21
22
23
# File 'lib/cuboid/data.rb', line 21

def application
  @application
end

Class Method Details

.clearObject

Clears all data.



61
62
63
64
# File 'lib/cuboid/data.rb', line 61

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

.dump(directory) ⇒ String

Returns Location of the dump directory.

Parameters:

  • directory (String)

    Location of the dump directory.

Returns:

  • (String)

    Location of the dump directory.



39
40
41
42
43
44
45
46
47
# File 'lib/cuboid/data.rb', line 39

def dump( directory )
    FileUtils.mkdir_p( directory )

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

    directory
end

.load(directory) ⇒ Data

Returns ‘self`.

Parameters:

  • directory (String)

    Location of the dump directory.

Returns:

  • (Data)

    ‘self`



52
53
54
55
56
57
58
# File 'lib/cuboid/data.rb', line 52

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

    self
end

.resetObject



23
24
25
# File 'lib/cuboid/data.rb', line 23

def reset
    @application = Application.new
end

.statisticsObject



27
28
29
30
31
32
33
# File 'lib/cuboid/data.rb', line 27

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