Class: JustizSync::Stream
- Inherits:
-
Object
- Object
- JustizSync::Stream
- Defined in:
- lib/justiz_sync/stream.rb
Instance Method Summary collapse
- #close(delete_unused = false) ⇒ Object
-
#initialize ⇒ Stream
constructor
A new instance of Stream.
- #sync(court) ⇒ Object
Constructor Details
#initialize ⇒ Stream
Returns a new instance of Stream.
3 4 5 6 7 |
# File 'lib/justiz_sync/stream.rb', line 3 def initialize @ids= [] @total_items = 0 @new_items = 0 end |
Instance Method Details
#close(delete_unused = false) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/justiz_sync/stream.rb', line 15 def close(delete_unused = false) all_ids = OpencrxCourt.all_ids unused = all_ids - @ids puts "#{@total_items} processed" puts "#{@new_items} new entrie(s)" if delete_unused OpencrxCourt.destroy(unused) puts "#{unused.length} deleted entrie(s)" end end |
#sync(court) ⇒ Object
9 10 11 12 13 |
# File 'lib/justiz_sync/stream.rb', line 9 def sync(court) @ids << court.id @total_items += 1 @new_items += OpencrxCourt.new(court).sync end |