Class: Youtube::Video

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#authorObject

Returns the value of attribute author.



28
29
30
# File 'lib/youtube/video.rb', line 28

def author
  @author
end

#comment_countObject

Returns the value of attribute comment_count.



37
38
39
# File 'lib/youtube/video.rb', line 37

def comment_count
  @comment_count
end

#descriptionObject

Returns the value of attribute description.



34
35
36
# File 'lib/youtube/video.rb', line 34

def description
  @description
end

#idObject

Returns the value of attribute id.



29
30
31
# File 'lib/youtube/video.rb', line 29

def id
  @id
end

#length_secondsObject

Returns the value of attribute length_seconds.



31
32
33
# File 'lib/youtube/video.rb', line 31

def length_seconds
  @length_seconds
end

#rating_avgObject

Returns the value of attribute rating_avg.



32
33
34
# File 'lib/youtube/video.rb', line 32

def rating_avg
  @rating_avg
end

#rating_countObject

Returns the value of attribute rating_count.



33
34
35
# File 'lib/youtube/video.rb', line 33

def rating_count
  @rating_count
end

#tagsObject

Returns the value of attribute tags.



38
39
40
# File 'lib/youtube/video.rb', line 38

def tags
  @tags
end

#thumbnail_urlObject

Returns the value of attribute thumbnail_url.



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

def thumbnail_url
  @thumbnail_url
end

#titleObject

Returns the value of attribute title.



30
31
32
# File 'lib/youtube/video.rb', line 30

def title
  @title
end

#upload_timeObject

Returns the value of attribute upload_time.



36
37
38
# File 'lib/youtube/video.rb', line 36

def upload_time
  @upload_time
end

#urlObject

Returns the value of attribute url.



40
41
42
# File 'lib/youtube/video.rb', line 40

def url
  @url
end

#view_countObject

Returns the value of attribute view_count.



35
36
37
# File 'lib/youtube/video.rb', line 35

def view_count
  @view_count
end

Instance Method Details

#to_xmlObject

Return self information as XML format.



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/youtube/video.rb', line 44

def to_xml
  xml = "<video>\n"
  instance_variables.each do |attr|
    value = instance_variable_get(attr).to_s
    value.gsub!(/<br \/>/, "\n")
    value.gsub!(/<.*?>/m, '')
    value.gsub!(/&/m, '&amp;')
    value.gsub!(/'/m, '&apos;')
    value.gsub!(/"/m, '&quot;')
    value.gsub!(/</m, '&lt;')
    value.gsub!(/>/m, '&gt;')
    attr.sub!(/@/, '')
    xml += "<#{attr}>#{value}</#{attr}>\n"
  end
  xml += "</video>\n"
end