Class: Termtter::RubytterProxy::LimitManager
- Inherits:
-
Object
- Object
- Termtter::RubytterProxy::LimitManager
- Defined in:
- lib/termtter/rubytter_proxy.rb
Instance Method Summary collapse
- #get ⇒ Object
-
#initialize(rubytter) ⇒ LimitManager
constructor
A new instance of LimitManager.
- #safe? ⇒ Boolean
Constructor Details
#initialize(rubytter) ⇒ LimitManager
Returns a new instance of LimitManager.
180 181 182 183 184 |
# File 'lib/termtter/rubytter_proxy.rb', line 180 def initialize(rubytter) @rubytter = rubytter @limit = nil @count = 0 end |
Instance Method Details
#get ⇒ Object
186 187 188 189 190 191 192 193 |
# File 'lib/termtter/rubytter_proxy.rb', line 186 def get @count += 1 if @count > 5 || !@limit @count = 0 @limit = @rubytter.limit_status end @limit end |
#safe? ⇒ Boolean
195 196 197 198 199 200 201 |
# File 'lib/termtter/rubytter_proxy.rb', line 195 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 |