Class: RBVIMEO::Video

Inherits:
Object
  • Object
show all
Defined in:
lib/rbvimeo/video.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, vimeo) ⇒ Video

Fetches data about a video from the Vimeo site id is the id of the the Vimeo video vimeo is an instance of RBVIMEO::Vimeo

To load a movie with vimeo id 339189: video = RBVIMEO::Video.new 339189, @vimeo



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/rbvimeo/video.rb', line 15

def initialize id, vimeo
  @thumbs = []
  @comments = []
  @id = id
  @vimeo = vimeo

  url = vimeo.generate_url({"method" => "vimeo.videos.getInfo",
    "video_id" => id, "api_key" => vimeo.api_key}, "read")

  xml_doc = @vimeo.get_xml(url)

  return @id = -1 if parse_xml(xml_doc).nil?
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



3
4
5
# File 'lib/rbvimeo/video.rb', line 3

def description
  @description
end

#durationObject (readonly)

Returns the value of attribute duration.



5
6
7
# File 'lib/rbvimeo/video.rb', line 5

def duration
  @duration
end

#heightObject (readonly)

Returns the value of attribute height.



4
5
6
# File 'lib/rbvimeo/video.rb', line 4

def height
  @height
end

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/rbvimeo/video.rb', line 3

def id
  @id
end

#number_of_commentsObject (readonly)

Returns the value of attribute number_of_comments.



4
5
6
# File 'lib/rbvimeo/video.rb', line 4

def number_of_comments
  @number_of_comments
end

#number_of_likesObject (readonly)

Returns the value of attribute number_of_likes.



3
4
5
# File 'lib/rbvimeo/video.rb', line 3

def number_of_likes
  @number_of_likes
end

#number_of_playsObject (readonly)

Returns the value of attribute number_of_plays.



3
4
5
# File 'lib/rbvimeo/video.rb', line 3

def number_of_plays
  @number_of_plays
end

#ownerObject (readonly)

Returns the value of attribute owner.



4
5
6
# File 'lib/rbvimeo/video.rb', line 4

def owner
  @owner
end

#tagsObject (readonly)

Returns the value of attribute tags.



4
5
6
# File 'lib/rbvimeo/video.rb', line 4

def tags
  @tags
end

#thumbsObject (readonly)

Returns the value of attribute thumbs.



5
6
7
# File 'lib/rbvimeo/video.rb', line 5

def thumbs
  @thumbs
end

#titleObject (readonly)

Returns the value of attribute title.



3
4
5
# File 'lib/rbvimeo/video.rb', line 3

def title
  @title
end

#upload_dateObject (readonly)

Returns the value of attribute upload_date.



3
4
5
# File 'lib/rbvimeo/video.rb', line 3

def upload_date
  @upload_date
end

#urlObject (readonly)

Returns the value of attribute url.



4
5
6
# File 'lib/rbvimeo/video.rb', line 4

def url
  @url
end

#widthObject (readonly)

Returns the value of attribute width.



4
5
6
# File 'lib/rbvimeo/video.rb', line 4

def width
  @width
end

Instance Method Details

#commentsObject



41
42
43
44
# File 'lib/rbvimeo/video.rb', line 41

def comments
  get_comments if @comments.empty?
  return @comments
end

#embed(width, height) ⇒ Object

Returns the code to embed the video



30
31
32
33
34
35
36
37
38
39
# File 'lib/rbvimeo/video.rb', line 30

def embed width, height
  string = <<EOF
<object type="application/x-shockwave-flash" width=#{width} height=#{height} data="http://www.vimeo.com/moogaloop.swf?clip_id=#{@id}&server=www.vimeo.com&fullscreen=0&show_title=0'&show_byline=0&showportrait=0&color=00ADEF">
<param name="quality" value="best" />
<param name="allowfullscreen" value="false" />
<param name="scale" value="showAll" />
<param name="movie" value="http://www.vimeo.com/moogaloop.swf?clip_id=#{@id}&server=www.vimeo.com&fullscreen=0&show_title=0&show_byline=0&showportrait=0&color=00ADEF" /></object>
EOF
string.gsub("\n", "")
end

#likesObject



46
47
48
# File 'lib/rbvimeo/video.rb', line 46

def likes
  @number_of_likes.to_i
end

#num_commentsObject



54
55
56
# File 'lib/rbvimeo/video.rb', line 54

def num_comments
  @number_of_comments.to_i
end

#playsObject



50
51
52
# File 'lib/rbvimeo/video.rb', line 50

def plays
  @number_of_plays.to_i
end