class Tinypass::Meter

Public Class Methods

create_time_based(rid, trial_period, lockout_period) click to toggle source
# File lib/tinypass/token/meter.rb, line 20
def self.create_time_based(rid, trial_period, lockout_period)
  access_token = AccessToken.new(rid)
  trial_end_time = Utils::parse_loose_period_in_secs(trial_period) + Time.now.to_i
  lockout_end_time = trial_end_time + Utils::parse_loose_period_in_secs(lockout_period)

  access_token.token_data[TokenData::METER_TYPE] = TokenData::METER_REMINDER
  access_token.token_data[TokenData::METER_TRIAL_ENDTIME] = trial_end_time
  access_token.token_data[TokenData::METER_LOCKOUT_ENDTIME] = lockout_end_time

  new(access_token)
end
create_view_based(rid, max_views, trial_period) click to toggle source
# File lib/tinypass/token/meter.rb, line 7
def self.create_view_based(rid, max_views, trial_period)
  access_token = AccessToken.new(rid)
  end_time = Utils.parse_loose_period_in_secs(trial_period) + Time.now.to_i

  access_token.token_data[TokenData::METER_TYPE] = TokenData::METER_REMINDER
  access_token.token_data[TokenData::METER_TRIAL_MAX_ACCESS_ATTEMPTS] = max_views
  access_token.token_data[TokenData::METER_TRIAL_ACCESS_ATTEMPTS] = 0
  access_token.token_data[TokenData::METER_TRIAL_ENDTIME] = end_time
  access_token.token_data[TokenData::METER_LOCKOUT_ENDTIME] = end_time

  new(access_token)
end
new(access_token) click to toggle source
# File lib/tinypass/token/meter.rb, line 3
def initialize(access_token)
  @access_token = access_token
end

Public Instance Methods

data() click to toggle source
# File lib/tinypass/token/meter.rb, line 44
def data
  @access_token.token_data
end
increment() click to toggle source
# File lib/tinypass/token/meter.rb, line 32
def increment
  data[TokenData::METER_TRIAL_ACCESS_ATTEMPTS] = trial_view_count + 1
end
lockout_end_time_secs() click to toggle source
# File lib/tinypass/token/meter.rb, line 72
def lockout_end_time_secs
  @access_token.lockout_end_time_secs
end
lockout_period_active?() click to toggle source
# File lib/tinypass/token/meter.rb, line 40
def lockout_period_active?
  @access_token.lockout_period_active?
end
meter_type() click to toggle source
# File lib/tinypass/token/meter.rb, line 64
def meter_type
  @access_token.meter_type
end
trial_dead?() click to toggle source
# File lib/tinypass/token/meter.rb, line 60
def trial_dead?
  @access_token.trial_dead?
end
trial_end_time_secs() click to toggle source
# File lib/tinypass/token/meter.rb, line 68
def trial_end_time_secs
  @access_token.trial_end_time_secs
end
trial_period_active?() click to toggle source
# File lib/tinypass/token/meter.rb, line 36
def trial_period_active?
  @access_token.trial_period_active?
end
trial_view_count() click to toggle source
# File lib/tinypass/token/meter.rb, line 52
def trial_view_count
  @access_token.trial_view_count
end
trial_view_limit() click to toggle source
# File lib/tinypass/token/meter.rb, line 56
def trial_view_limit
  @access_token.trial_view_limit
end
view_based?() click to toggle source
# File lib/tinypass/token/meter.rb, line 48
def view_based?
  @access_token.meter_view_based?
end