Class: LinkThumbnailer::Models::Video

Inherits:
LinkThumbnailer::Model show all
Defined in:
lib/link_thumbnailer/models/video.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from LinkThumbnailer::Model

#to_json

Constructor Details

#initialize(src, size = nil) ⇒ Video

Returns a new instance of Video.



10
11
12
13
14
15
16
17
# File 'lib/link_thumbnailer/models/video.rb', line 10

def initialize(src, size = nil)
  @src        = src
  @id         = parser.id
  @size       = size || parser.size
  @duration   = parser.duration
  @provider   = parser.provider
  @embed_code = parser.embed_code
end

Instance Attribute Details

#durationObject (readonly)

Returns the value of attribute duration.



8
9
10
# File 'lib/link_thumbnailer/models/video.rb', line 8

def duration
  @duration
end

#embed_codeObject (readonly)

Returns the value of attribute embed_code.



8
9
10
# File 'lib/link_thumbnailer/models/video.rb', line 8

def embed_code
  @embed_code
end

#idObject (readonly)

Returns the value of attribute id.



8
9
10
# File 'lib/link_thumbnailer/models/video.rb', line 8

def id
  @id
end

#providerObject (readonly)

Returns the value of attribute provider.



8
9
10
# File 'lib/link_thumbnailer/models/video.rb', line 8

def provider
  @provider
end

#sizeObject (readonly)

Returns the value of attribute size.



8
9
10
# File 'lib/link_thumbnailer/models/video.rb', line 8

def size
  @size
end

#srcObject (readonly)

Returns the value of attribute src.



8
9
10
# File 'lib/link_thumbnailer/models/video.rb', line 8

def src
  @src
end

Instance Method Details

#as_jsonObject



23
24
25
26
27
28
29
30
31
32
# File 'lib/link_thumbnailer/models/video.rb', line 23

def as_json(*)
  {
    id:         id,
    src:        src.to_s,
    size:       size,
    duration:   duration,
    provider:   provider,
    embed_code: embed_code
  }
end

#to_sObject



19
20
21
# File 'lib/link_thumbnailer/models/video.rb', line 19

def to_s
  src.to_s
end