Class: LLMed::Application::Snapshot
- Inherits:
-
Object
- Object
- LLMed::Application::Snapshot
- Defined in:
- lib/llmed/application.rb
Instance Attribute Summary collapse
-
#snapshot_file ⇒ Object
readonly
Returns the value of attribute snapshot_file.
Instance Method Summary collapse
- #diff(other_contexts) ⇒ Object
-
#initialize(snapshot_file) ⇒ Snapshot
constructor
A new instance of Snapshot.
- #refresh(contexts) ⇒ Object
- #sync(default) ⇒ Object
Constructor Details
#initialize(snapshot_file) ⇒ Snapshot
Returns a new instance of Snapshot.
67 68 69 70 |
# File 'lib/llmed/application.rb', line 67 def initialize(snapshot_file) @snapshot_file = snapshot_file @contexts = [] end |
Instance Attribute Details
#snapshot_file ⇒ Object (readonly)
Returns the value of attribute snapshot_file.
65 66 67 |
# File 'lib/llmed/application.rb', line 65 def snapshot_file @snapshot_file end |
Instance Method Details
#diff(other_contexts) ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/llmed/application.rb', line 82 def diff(other_contexts) diffs = {} other_contexts.each do |other_ctx| current_ctx = @contexts[other_ctx.name] result = line_diff(current_ctx['message'], other_ctx.raw) # omit not changes if !result.all?{|op, line| op == '=:'} diffs[other_ctx.name] = result end end diffs end |
#refresh(contexts) ⇒ Object
77 78 79 80 |
# File 'lib/llmed/application.rb', line 77 def refresh(contexts) @contexts = contexts.map{ |ctx| [ctx.name, {'name' => ctx.name, 'message' => ctx.raw}]}.to_h dump end |
#sync(default) ⇒ Object
72 73 74 75 |
# File 'lib/llmed/application.rb', line 72 def sync(default) load(default) dump end |