Class: Cuboid::Data
- Defined in:
- lib/cuboid/data.rb,
lib/cuboid/data/application.rb
Overview
Stores and provides access to the data of the system.
Defined Under Namespace
Classes: Application, Error
Class Attribute Summary collapse
Class Method Summary collapse
-
.clear ⇒ Object
Clears all data.
-
.dump(directory) ⇒ String
Location of the dump directory.
-
.load(directory) ⇒ Data
‘self`.
- .reset ⇒ Object
- .statistics ⇒ Object
Class Attribute Details
.application ⇒ Framework
21 22 23 |
# File 'lib/cuboid/data.rb', line 21 def application @application end |
Class Method Details
.clear ⇒ Object
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.
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`.
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 |
.reset ⇒ Object
23 24 25 |
# File 'lib/cuboid/data.rb', line 23 def reset @application = Application.new end |
.statistics ⇒ Object
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 |