Class: Poke::API::Auth::Ticket

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/poke-api/auth/ticket.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logging

formatter=, log_level=, #logger

Constructor Details

#initializeTicket

Returns a new instance of Ticket.



8
9
10
11
12
# File 'lib/poke-api/auth/ticket.rb', line 8

def initialize
  @expire = nil
  @start  = nil
  @ends   = nil
end

Instance Attribute Details

#endsObject (readonly)

Returns the value of attribute ends.



6
7
8
# File 'lib/poke-api/auth/ticket.rb', line 6

def ends
  @ends
end

#expireObject (readonly)

Returns the value of attribute expire.



6
7
8
# File 'lib/poke-api/auth/ticket.rb', line 6

def expire
  @expire
end

#startObject (readonly)

Returns the value of attribute start.



6
7
8
# File 'lib/poke-api/auth/ticket.rb', line 6

def start
  @start
end

Instance Method Details

#get_ticketObject



30
31
32
33
# File 'lib/poke-api/auth/ticket.rb', line 30

def get_ticket
  return false unless check_ticket
  true
end

#has_ticket?Boolean

Returns:

  • (Boolean)


14
15
16
17
# File 'lib/poke-api/auth/ticket.rb', line 14

def has_ticket?
  return true if @start && @ends && @expire
  false
end

#is_new_ticket?(new_ticket_time) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
28
# File 'lib/poke-api/auth/ticket.rb', line 25

def is_new_ticket?(new_ticket_time)
  return true unless @expire && new_ticket_time > @expire
  false
end

#set_ticket(auth) ⇒ Object



19
20
21
22
23
# File 'lib/poke-api/auth/ticket.rb', line 19

def set_ticket(auth)
  @expire = auth[:expire_timestamp_ms]
  @start  = auth[:start]
  @ends   = auth[:end]
end