Class: SocialNet::Facebook::Models::Video

Inherits:
Object
  • Object
show all
Defined in:
lib/social_net/facebook/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.



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

def initialize(attrs={})
  @id = attrs['id']
  @link = attrs['link']
  @video_url = attrs['video_url']
  @thumbnail_url = attrs['thumbnail_url']
  @caption = attrs['caption'] if attrs['caption']
end

Instance Attribute Details

#captionObject (readonly)

Returns the value of attribute caption.



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

def caption
  @caption
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

Returns the value of attribute link.



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

def link
  @link
end

#thumbnail_urlObject (readonly)

Returns the value of attribute thumbnail_url.



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

def thumbnail_url
  @thumbnail_url
end

#video_urlObject (readonly)

Returns the value of attribute video_url.



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

def video_url
  @video_url
end

Class Method Details

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

Returns the existing Facebook 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 Facebook video’s media id.

Returns:



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

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

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

Returns the existing Facebook 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 Facebook video’s media id.

Returns:

Raises:

  • (SocialNet::Errors::UnknownVideo)

    if the video is not found.



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

def self.find_by!(params = {})
  if params[:video_id] && params[:username]
    find_by_username_and_video_id! params[:username], params[:video_id]
  end
end