Class: ChocolateRain::YVideo
- Inherits:
-
Object
- Object
- ChocolateRain::YVideo
- Defined in:
- lib/chocolate_rain/y_video.rb
Constant Summary collapse
- @@y_creds =
{}
- @@y_conn =
YouTubeIt::Client.new(:username => @@y_creds[:username] , :password => @@y_creds[:password] , :dev_key => @@y_creds[:dev_key])
- @@s3_creds =
YAML.load(File.open("config/s3.yml"))
Instance Attribute Summary collapse
-
#category ⇒ Object
Returns the value of attribute category.
-
#comments ⇒ Object
Returns the value of attribute comments.
-
#commentVote ⇒ Object
Returns the value of attribute commentVote.
-
#description ⇒ Object
Returns the value of attribute description.
-
#embed ⇒ Object
Returns the value of attribute embed.
-
#file_object ⇒ Object
Returns the value of attribute file_object.
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#keywords ⇒ Object
Returns the value of attribute keywords.
-
#list ⇒ Object
Returns the value of attribute list.
-
#rate ⇒ Object
Returns the value of attribute rate.
-
#syndicate ⇒ Object
Returns the value of attribute syndicate.
-
#title ⇒ Object
Returns the value of attribute title.
-
#videoRespond ⇒ Object
Returns the value of attribute videoRespond.
Instance Method Summary collapse
-
#initialize ⇒ YVideo
constructor
A new instance of YVideo.
- #save ⇒ Object
- #to_hash ⇒ Object
- #to_upload_options_hash ⇒ Object
- #upload ⇒ Object
Constructor Details
#initialize ⇒ YVideo
Returns a new instance of YVideo.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/chocolate_rain/y_video.rb', line 23 def initialize @filename = nil @title = "" @description = "Testimonial Video" @category = "Entertainment" @keywords = %w[herman cain whyhermancain republican politics testimonal donate donation] @list = "denied" @comments = "denied" @rate = "denied" @commentVote = "denied" @videoRespond = "denied" @embed = "denied" @syndicate = "denied" @private = true end |
Instance Attribute Details
#category ⇒ Object
Returns the value of attribute category.
6 7 8 |
# File 'lib/chocolate_rain/y_video.rb', line 6 def category @category end |
#comments ⇒ Object
Returns the value of attribute comments.
6 7 8 |
# File 'lib/chocolate_rain/y_video.rb', line 6 def comments @comments end |
#commentVote ⇒ Object
Returns the value of attribute commentVote.
6 7 8 |
# File 'lib/chocolate_rain/y_video.rb', line 6 def commentVote @commentVote end |
#description ⇒ Object
Returns the value of attribute description.
6 7 8 |
# File 'lib/chocolate_rain/y_video.rb', line 6 def description @description end |
#embed ⇒ Object
Returns the value of attribute embed.
6 7 8 |
# File 'lib/chocolate_rain/y_video.rb', line 6 def @embed end |
#file_object ⇒ Object
Returns the value of attribute file_object.
6 7 8 |
# File 'lib/chocolate_rain/y_video.rb', line 6 def file_object @file_object end |
#filename ⇒ Object
Returns the value of attribute filename.
6 7 8 |
# File 'lib/chocolate_rain/y_video.rb', line 6 def filename @filename end |
#keywords ⇒ Object
Returns the value of attribute keywords.
6 7 8 |
# File 'lib/chocolate_rain/y_video.rb', line 6 def keywords @keywords end |
#list ⇒ Object
Returns the value of attribute list.
6 7 8 |
# File 'lib/chocolate_rain/y_video.rb', line 6 def list @list end |
#rate ⇒ Object
Returns the value of attribute rate.
6 7 8 |
# File 'lib/chocolate_rain/y_video.rb', line 6 def rate @rate end |
#syndicate ⇒ Object
Returns the value of attribute syndicate.
6 7 8 |
# File 'lib/chocolate_rain/y_video.rb', line 6 def syndicate @syndicate end |
#title ⇒ Object
Returns the value of attribute title.
6 7 8 |
# File 'lib/chocolate_rain/y_video.rb', line 6 def title @title end |
#videoRespond ⇒ Object
Returns the value of attribute videoRespond.
6 7 8 |
# File 'lib/chocolate_rain/y_video.rb', line 6 def videoRespond @videoRespond end |
Instance Method Details
#save ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/chocolate_rain/y_video.rb', line 56 def save begin AWS::S3::S3Object.store(self.filename, self.file_object, @@s3_creds[(Rails.env)]["bucket"], :access => :public_read) begin self.upload return true rescue Exception => e puts "Upload Failed. #{e.}" end rescue Exception => e puts "Could not complete save. #{e.}" return false end end |
#to_hash ⇒ Object
39 40 41 |
# File 'lib/chocolate_rain/y_video.rb', line 39 def to_hash self.instance_variables.inject({}) { |hash,var| hash[var.to_s.delete("@").to_sym] = self.instance_variable_get(var); hash } end |
#to_upload_options_hash ⇒ Object
43 44 45 |
# File 'lib/chocolate_rain/y_video.rb', line 43 def self.instance_variables.inject({}) { |hash,var| (hash[var.to_s.delete("@").to_sym] = self.instance_variable_get(var) unless (["filename", "file_object"].include?(var.to_s.delete("@")))); hash } end |
#upload ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/chocolate_rain/y_video.rb', line 47 def upload resp = @@y_conn.video_upload(self.file_object, self. ) puts "Response: #{resp.inspect}" puts "***" puts "ID: #{resp.video_id.split(":").last}" return true end |