class UserData

Class handling user data. Takes a data object extended Hashie::Extensions::DeepFind

Attributes

follower_count[R]
following_count[R]
full_name[R]
id[R]
username[R]

Public Class Methods

new(data) click to toggle source
# File lib/botinsta/data/user_data.rb, line 7
def initialize(data)
  @id              = data.deep_find('pk')
  @username        = data.deep_find('username')
  @full_name       = data.deep_find('full_name')
  @following_count = data.deep_find('following_count')
  @follower_count  = data.deep_find('follower_count')
  @is_private      = data.deep_find('is_private')
end

Public Instance Methods

delete_from_db(table) click to toggle source
# File lib/botinsta/data/user_data.rb, line 24
def delete_from_db(table)
  table.where(user_id: @id).delete
end
exists_in_db?(table) click to toggle source
# File lib/botinsta/data/user_data.rb, line 28
def exists_in_db?(table)
  !table.where(user_id: @id).empty?
end
insert_into_db(table) click to toggle source
# File lib/botinsta/data/user_data.rb, line 20
def insert_into_db(table)
  table.insert(user_id: @id, username: @username, follow_time: Time.now)
end
private?() click to toggle source
# File lib/botinsta/data/user_data.rb, line 16
def private?
  @is_private
end