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
# File 'lib/social_net/instagram/models/video.rb', line 11

def initialize(attrs = {})
  @id = attrs['id']
  @video_url = attrs['video_url']
  @thumbnail_url = attrs['thumbnail_url']
  @link = attrs['link']
  @caption = attrs['caption'] if attrs['caption']
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

#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

Returns the value of attribute link.



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

def link
  @link
end

#thumbnail_urlObject (readonly)

Returns the value of attribute thumbnail_url.



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

def thumbnail_url
  @thumbnail_url
end

#video_urlObject (readonly)

Returns the value of attribute video_url.



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

def video_url
  @video_url
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:



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

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.



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

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