Class: Tuiter::RateLimit

Inherits:
Object
  • Object
show all
Defined in:
lib/tuiter/data/rate_limit.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data = nil) ⇒ RateLimit

Returns a new instance of RateLimit.



10
11
12
13
14
15
16
17
18
# File 'lib/tuiter/data/rate_limit.rb', line 10

def initialize(data = nil)
  unless data.nil?
    @reset_time_in_seconds = Time.at(data["reset_time_in_seconds"].to_i)
    @reset_time = Time.parse(data["reset_time"]) if data["reset_time"]
    @reset_window = @reset_time - Time.now if @reset_time
    @remaining_hits = data["remaining_hits"].to_i
    @hourly_limit = data["hourly_limit"].to_i
  end
end

Instance Attribute Details

#hourly_limitObject

Returns the value of attribute hourly_limit.



8
9
10
# File 'lib/tuiter/data/rate_limit.rb', line 8

def hourly_limit
  @hourly_limit
end

#remaining_hitsObject

Returns the value of attribute remaining_hits.



7
8
9
# File 'lib/tuiter/data/rate_limit.rb', line 7

def remaining_hits
  @remaining_hits
end

#reset_timeObject

Returns the value of attribute reset_time.



4
5
6
# File 'lib/tuiter/data/rate_limit.rb', line 4

def reset_time
  @reset_time
end

#reset_time_in_secondsObject

Returns the value of attribute reset_time_in_seconds.



5
6
7
# File 'lib/tuiter/data/rate_limit.rb', line 5

def reset_time_in_seconds
  @reset_time_in_seconds
end

#reset_windowObject

Returns the value of attribute reset_window.



6
7
8
# File 'lib/tuiter/data/rate_limit.rb', line 6

def reset_window
  @reset_window
end