Class: SocialNet::Instagram::Models::Video

Inherits:
Object
  • Object
show all
Defined in:
lib/social_net/instagram/models/video.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Video

Returns a new instance of Video.



11
12
13
14
15
16
17
18
# File 'lib/social_net/instagram/models/video.rb', line 11

def initialize(attrs = {})
  @id = attrs['id']
  @caption = attrs['caption']['text'] if attrs['caption']
  @likes = attrs['likes']['count']
  @file = attrs['videos']['standard_resolution']['url']
  @thumbnail = attrs['images']['standard_resolution']['url']
  @link = attrs['link']
end

Instance Attribute Details

#captionObject (readonly)

Returns the value of attribute caption.



9
10
11
# File 'lib/social_net/instagram/models/video.rb', line 9

def caption
  @caption
end

#fileObject (readonly)

Returns the value of attribute file.



9
10
11
# File 'lib/social_net/instagram/models/video.rb', line 9

def file
  @file
end

#idObject (readonly)

Returns the value of attribute id.



9
10
11
# File 'lib/social_net/instagram/models/video.rb', line 9

def id
  @id
end

#likesObject (readonly)

Returns the value of attribute likes.



9
10
11
# File 'lib/social_net/instagram/models/video.rb', line 9

def likes
  @likes
end

Returns the value of attribute link.



9
10
11
# File 'lib/social_net/instagram/models/video.rb', line 9

def link
  @link
end

#thumbnailObject (readonly)

Returns the value of attribute thumbnail.



9
10
11
# File 'lib/social_net/instagram/models/video.rb', line 9

def thumbnail
  @thumbnail
end

Class Method Details

.find_by(params = {}) ⇒ SocialNet::Instagram::Models::Video?

Returns the existing Instagram video matching the provided attributes or nil when the video is not found.

Parameters:

  • params (Hash) (defaults to: {})

    the attributes to find a video by.

Options Hash (params):

  • :media_id (String)

    The Instagram video’s media id.

Returns:



27
28
29
30
31
# File 'lib/social_net/instagram/models/video.rb', line 27

def self.find_by(params = {})
  find_by! params
rescue Errors::UnknownVideo
  nil
end

.find_by!(params = {}) ⇒ SocialNet::Instagram::Models::Video?

Returns the existing Instagram video matching the provided attributes or raises an error when the video is not found.

Parameters:

  • params (Hash) (defaults to: {})

    the attributes to find a video by.

Options Hash (params):

  • :media_id (String)

    The Instagram video’s media id.

Returns:

Raises:

  • (SocialNet::Errors::UnknownVideo)

    if the video is not found.



41
42
43
44
45
# File 'lib/social_net/instagram/models/video.rb', line 41

def self.find_by!(params = {})
  if params[:shortcode]
    find_by_shortcode! params[:shortcode]
  end
end