Class: Dream::Spectre
- Inherits:
-
Object
- Object
- Dream::Spectre
- Defined in:
- lib/dream.rb
Instance Method Summary collapse
- #author(book) ⇒ Object
- #clean(path) ⇒ Object
- #error ⇒ Object
- #finished ⇒ Object
- #info ⇒ Object
-
#initialize(library) ⇒ Spectre
constructor
A new instance of Spectre.
- #manuscript(clear) ⇒ Object
- #record(status, directory, message) ⇒ Object
- #record_finished ⇒ Object
- #record_start ⇒ Object
- #save(path) ⇒ Object
- #started ⇒ Object
- #success ⇒ Object
- #time_records(name) ⇒ Object
- #warning ⇒ Object
- #watch(name) ⇒ Object
Constructor Details
#initialize(library) ⇒ Spectre
Returns a new instance of Spectre.
6 7 8 9 10 11 12 |
# File 'lib/dream.rb', line 6 def initialize(library) @library = library @messages = library['records']['messages'] @format = library['records']['format'] @watches = {} @book = Array.new end |
Instance Method Details
#author(book) ⇒ Object
70 71 72 |
# File 'lib/dream.rb', line 70 def (book) @book = book end |
#clean(path) ⇒ Object
90 91 92 |
# File 'lib/dream.rb', line 90 def clean(path) return FileUtils.rm_rf(path) end |
#error ⇒ Object
58 59 60 |
# File 'lib/dream.rb', line 58 def error return @messages['error'] end |
#finished ⇒ Object
42 43 44 |
# File 'lib/dream.rb', line 42 def finished return @messages['finished'] end |
#info ⇒ Object
50 51 52 |
# File 'lib/dream.rb', line 50 def info return @messages['info'] end |
#manuscript(clear) ⇒ Object
62 63 64 65 66 67 68 |
# File 'lib/dream.rb', line 62 def manuscript(clear) replica = @book if clear @book = Array.new end return replica end |
#record(status, directory, message) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/dream.rb', line 14 def record(status, directory, ) = Time.now path = directory.split("/") node = branch(path[0..-2]) record = timeline(path[-1], , status, ) node.push(record) end |
#record_finished ⇒ Object
26 27 28 |
# File 'lib/dream.rb', line 26 def record_finished() watch(@messages['finished']) end |
#record_start ⇒ Object
22 23 24 |
# File 'lib/dream.rb', line 22 def record_start() watch(@messages['started']) end |
#save(path) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/dream.rb', line 74 def save(path) path = path.eql?(nil) ? '.' : path iteration = 0 name = record_name(iteration) record_path = "#{path}/#{name}" while File.exist?(record_path) iteration = iteration + 1 name = record_name(iteration) record_path = "#{path}/#{name}" end File.open(record_path, "w+") do |f| f.puts(@book.to_json) end return record_path end |
#started ⇒ Object
38 39 40 |
# File 'lib/dream.rb', line 38 def started return @messages['started'] end |
#success ⇒ Object
46 47 48 |
# File 'lib/dream.rb', line 46 def success return @messages['success'] end |
#time_records(name) ⇒ Object
34 35 36 |
# File 'lib/dream.rb', line 34 def time_records(name) return @watches[:"#{name}"] end |
#warning ⇒ Object
54 55 56 |
# File 'lib/dream.rb', line 54 def warning return @messages['warning'] end |
#watch(name) ⇒ Object
30 31 32 |
# File 'lib/dream.rb', line 30 def watch(name) @watches[:"#{name}"] = () end |