class Termtter::RubytterProxy::LimitManager

Public Class Methods

new(rubytter) click to toggle source
# File lib/termtter/rubytter_proxy.rb, line 181
def initialize(rubytter)
  @rubytter = rubytter
  @limit = nil
  @count = 0
end

Public Instance Methods

get() click to toggle source
# File lib/termtter/rubytter_proxy.rb, line 187
def get
  @count += 1
  if @count > 5 || !@limit
    @count = 0
    @limit = @rubytter.limit_status
  end
  @limit
end
safe?() click to toggle source
# File lib/termtter/rubytter_proxy.rb, line 196
def safe?
  limit = self.get
  threshold =
    [(Time.parse(limit.reset_time) - Time.now) / 3600 - 0.1, 0.1].max *
    limit.hourly_limit
  threshold < limit.remaining_hits
end