Class: NSIVideoConvert::Client
- Inherits:
-
Object
- Object
- NSIVideoConvert::Client
- Defined in:
- lib/nsivideoconvert/client.rb,
lib/nsivideoconvert/configuration.rb
Defined Under Namespace
Classes: Configuration
Class Method Summary collapse
-
.configure { ... } ⇒ Object
Pre-configure the NSIVideoConvert module with default params for the NSIVideoConvert::Client.
Instance Method Summary collapse
-
#convert(options = {}) ⇒ Hash
Send a video be converted by a nsi.videoconvert node.
-
#done(key) ⇒ Hash
Verify if a video is already converted.
-
#initialize(params = {}) ⇒ Client
constructor
Initialize a client to a VideoConvert node.
Constructor Details
#initialize(params = {}) ⇒ Client
if you had used the ‘configure’ method, you can use it without parameters and those you provided before will be used (see Client#configure)
Initialize a client to a VideoConvert node
23 24 25 26 27 28 29 |
# File 'lib/nsivideoconvert/client.rb', line 23 def initialize(params = {}) params = Configuration.settings.merge(params) @user = params[:user] @password = params[:password] @host = params[:host] @port = params[:port] end |
Class Method Details
.configure { ... } ⇒ Object
Pre-configure the NSIVideoConvert module with default params for the NSIVideoConvert::Client
125 126 127 |
# File 'lib/nsivideoconvert/client.rb', line 125 def self.configure(&block) Configuration.instance_eval(&block) end |
Instance Method Details
#convert(options = {}) ⇒ Hash
the filename is very importante, the videoconvert node will use the proper coding/encoding option for the video type
if provided both video_link and file options, file will be ignored and the client will download the video instead
Send a video be converted by a nsi.videoconvert node
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/nsivideoconvert/client.rb', line 77 def convert( = {}) @request_data = Hash.new if [:video_link] insert_download_data elsif [:sam_uid] && [:filename] file_data = {:sam_uid => [:sam_uid], :filename => [:filename]} @request_data.merge! file_data elsif [:file] && [:filename] file_data = {:video => [:file], :filename => [:filename]} @request_data.merge! file_data else raise NSIVideoConvert::Errors::Client::MissingParametersError end insert_callback_data request = prepare_request :POST, @request_data.to_json execute_request(request) end |
#done(key) ⇒ Hash
Verify if a video is already converted
109 110 111 112 |
# File 'lib/nsivideoconvert/client.rb', line 109 def done(key) request = prepare_request :GET, {:key => key}.to_json execute_request(request) end |