class TokenStrans
Public Class Methods
new(key, fields={})
click to toggle source
# File lib/token.rb, line 5 def initialize (key, fields={}) @key = key @create_at = Time.now @minute_validate = fields[:minutes] @token = fields['token'] end
Public Instance Methods
date_in_format()
click to toggle source
# File lib/token.rb, line 12 def date_in_format() today = Time.now today.strftime("%a, %d %b %Y %H:%M:%S GMT") end
header()
click to toggle source
# File lib/token.rb, line 17 def header head ={} head['Accept-Language'] = "en" head['Content-Type'] = "application/json" head['X-Auth-Token'] = @token if @token head['X-Api-Key'] = @key head['Date'] = date_in_format() head end
to_json()
click to toggle source
# File lib/token.rb, line 31 def to_json { 'key' => @key, 'token' => @token, 'minute_validate' => @minute_validate }.to_json end
valid?()
click to toggle source
# File lib/token.rb, line 27 def valid? !@token.nil? && (Time.now - 10 * 60) <= @create_at end