class MediaData
Class handling media data. Takes a data object extended Hashie::Extensions::DeepFind
Attributes
id[R]
owner[R]
shortcode[R]
text[R]
Public Class Methods
new(data)
click to toggle source
# File lib/botinsta/data/media_data.rb, line 7 def initialize(data) @id = data.deep_find('id') @owner = data.deep_find('owner')['id'] @is_video = data.deep_find('is_video') @comments_disabled = data.deep_find('comments_disabled') @text = data.deep_find('text') @tags = @text.nil? ? [] : @text.scan(/#[a-zA-Z0-9]+/) @shortcode = data.deep_find('shortcode') end
Public Instance Methods
blacklisted_tag?(tag_blacklist)
click to toggle source
# File lib/botinsta/data/media_data.rb, line 23 def blacklisted_tag?(tag_blacklist) !(@tags & tag_blacklist).empty? end
comments_disabled?()
click to toggle source
# File lib/botinsta/data/media_data.rb, line 19 def comments_disabled? @comments_disabled end
delete_from_db(table)
click to toggle source
# File lib/botinsta/data/media_data.rb, line 35 def delete_from_db(table) table.where(media_id: @id).delete end
exists_in_db?(table)
click to toggle source
# File lib/botinsta/data/media_data.rb, line 39 def exists_in_db?(table) !table.where(media_id: @id).empty? end
insert_into_db(table)
click to toggle source
# File lib/botinsta/data/media_data.rb, line 31 def insert_into_db(table) table.insert(media_id: @id, user_id: @owner, shortcode: @shortcode, like_time: Time.now) end
video?()
click to toggle source
# File lib/botinsta/data/media_data.rb, line 27 def video? @is_video end