Class: LiveJournal::Request::SyncItems
- Defined in:
- lib/livejournal/sync.rb
Instance Attribute Summary collapse
-
#fetched ⇒ Object
readonly
Returns the value of attribute fetched.
-
#syncitems ⇒ Object
readonly
Returns the value of attribute syncitems.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(user, syncitems = nil, lastsync = nil) ⇒ SyncItems
constructor
A new instance of SyncItems.
- #run ⇒ Object
Methods inherited from Req
#dryrun!, #dumpresponse, #verbose!
Constructor Details
#initialize(user, syncitems = nil, lastsync = nil) ⇒ SyncItems
Returns a new instance of SyncItems.
39 40 41 42 43 |
# File 'lib/livejournal/sync.rb', line 39 def initialize(user, syncitems=nil, lastsync=nil) super(user, 'syncitems') @syncitems = syncitems || {} @request['lastsync'] = lastsync if lastsync end |
Instance Attribute Details
#fetched ⇒ Object (readonly)
Returns the value of attribute fetched.
38 39 40 |
# File 'lib/livejournal/sync.rb', line 38 def fetched @fetched end |
#syncitems ⇒ Object (readonly)
Returns the value of attribute syncitems.
38 39 40 |
# File 'lib/livejournal/sync.rb', line 38 def syncitems @syncitems end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
38 39 40 |
# File 'lib/livejournal/sync.rb', line 38 def total @total end |
Class Method Details
.subset_items(syncitems, want_type = 'L') ⇒ Object
60 61 62 63 64 65 66 67 68 |
# File 'lib/livejournal/sync.rb', line 60 def self.subset_items(syncitems, want_type='L') items = {} syncitems.each do |item, time| next unless item =~ /^(.)-(\d+)$/ type, id = $1, $2.to_i items[id] = time if type == want_type end items end |
Instance Method Details
#run ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/livejournal/sync.rb', line 45 def run super lasttime = nil @fetched = 0 @total = @result['sync_total'].to_i each_in_array('sync') do |item| item, time = item['item'], item['time'] next if @syncitems.has_key? item @fetched += 1 lasttime = time if lasttime.nil? or time > lasttime @syncitems[item] = time end lasttime end |