Class: FileDiffMap
- Inherits:
-
Object
- Object
- FileDiffMap
- Defined in:
- lib/file_diff_map.rb
Defined Under Namespace
Classes: Entry
Instance Attribute Summary collapse
-
#diff_map ⇒ Object
readonly
Returns the value of attribute diff_map.
Instance Method Summary collapse
- #add(name, size) ⇒ Object
- #entries ⇒ Object
-
#initialize ⇒ FileDiffMap
constructor
A new instance of FileDiffMap.
- #local_entries ⇒ Object
- #update(name, size) ⇒ Object
Constructor Details
#initialize ⇒ FileDiffMap
Returns a new instance of FileDiffMap.
6 7 8 |
# File 'lib/file_diff_map.rb', line 6 def initialize @diff_map = {} end |
Instance Attribute Details
#diff_map ⇒ Object (readonly)
Returns the value of attribute diff_map.
5 6 7 |
# File 'lib/file_diff_map.rb', line 5 def diff_map @diff_map end |
Instance Method Details
#add(name, size) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/file_diff_map.rb', line 11 def add(name, size) raise "file #{name} already exists!" if(diff_map[name]) diff_map[name] = Entry.new(name, size, :local) :local end |
#entries ⇒ Object
38 39 40 |
# File 'lib/file_diff_map.rb', line 38 def entries diff_map.values end |
#local_entries ⇒ Object
42 43 44 |
# File 'lib/file_diff_map.rb', line 42 def local_entries diff_map.values.find_all {|e| e.status == :local} end |
#update(name, size) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/file_diff_map.rb', line 19 def update(name, size) if(diff_map[name]) if diff_map[name].size == size diff_map[name].status = :match else diff_map[name].status = :diff end else diff_map[name] = Entry.new(name, size, :remote) :remote end end |