Class: JustizSync::Transfer
- Inherits:
-
Object
- Object
- JustizSync::Transfer
- Defined in:
- lib/justiz_sync/cli.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(options) ⇒ Transfer
constructor
A new instance of Transfer.
- #sync ⇒ Object
- #sync_courts(courts) ⇒ Object
- #sync_state(state) ⇒ Object
Constructor Details
#initialize(options) ⇒ Transfer
25 26 27 28 29 |
# File 'lib/justiz_sync/cli.rb', line 25 def initialize() = STDOUT.sync = true open_connection end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
24 25 26 |
# File 'lib/justiz_sync/cli.rb', line 24 def end |
Instance Method Details
#sync ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/justiz_sync/cli.rb', line 31 def sync states = scraper.states total = 0 states.keys.each do |state| total += sync_state(state) end puts "Total #{total} synchronized" end |
#sync_courts(courts) ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/justiz_sync/cli.rb', line 47 def sync_courts(courts) courts.each_with_index do |court, index| OpencrxCourt.sync(court) puts if verbose && index && (index % 20 == 0) putc('.') if verbose end puts if verbose end |
#sync_state(state) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/justiz_sync/cli.rb', line 40 def sync_state(state) courts = scraper.contacts_for(state) puts "Syncing #{state} #{courts.length} courts" sync_courts(courts) courts.length end |