Class: Snapcat::Media

Inherits:
Object
  • Object
show all
Defined in:
lib/snapcat/media.rb

Defined Under Namespace

Classes: Type

Instance Method Summary collapse

Constructor Details

#initialize(data, type_code = nil) ⇒ Media

Returns a new instance of Media.



3
4
5
6
# File 'lib/snapcat/media.rb', line 3

def initialize(data, type_code = nil)
  @data = Crypt.decrypt(data)
  @type = Type.new(code: type_code, data: @data)
end

Instance Method Details

#file_extensionObject



8
9
10
# File 'lib/snapcat/media.rb', line 8

def file_extension
  @type.file_extension
end

#generate_id(username) ⇒ Object



16
17
18
# File 'lib/snapcat/media.rb', line 16

def generate_id(username)
  "#{username.upcase}~#{Timestamp.macro}"
end

#image?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/snapcat/media.rb', line 12

def image?
  @type.image?
end

#to_sObject



20
21
22
# File 'lib/snapcat/media.rb', line 20

def to_s
  @data
end

#type_codeObject



24
25
26
# File 'lib/snapcat/media.rb', line 24

def type_code
  @type.code
end

#video?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/snapcat/media.rb', line 28

def video?
  @type.video?
end