Class: Swftly
- Inherits:
-
Object
- Object
- Swftly
- Defined in:
- lib/swftly.rb
Instance Attribute Summary collapse
-
#auto_process ⇒ Object
Returns the value of attribute auto_process.
-
#converted ⇒ Object
readonly
Returns the value of attribute converted.
-
#converter_response_code ⇒ Object
readonly
Returns the value of attribute converter_response_code.
-
#fetcher_response_code ⇒ Object
readonly
Returns the value of attribute fetcher_response_code.
-
#markup ⇒ Object
readonly
Returns the value of attribute markup.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
-
#runtime ⇒ Object
readonly
Returns the value of attribute runtime.
-
#swf_path ⇒ Object
Returns the value of attribute swf_path.
Instance Method Summary collapse
-
#initialize(swf_path = '', auto_process = true) ⇒ Swftly
constructor
init w/ a swf, through false for the second param if you don’t wanna immediately trigger post-conversion processing.
-
#process! ⇒ Object
perform and process the second fetching.
-
#swiff ⇒ Object
post the swf to swiffy and parse/process the results.
Constructor Details
#initialize(swf_path = '', auto_process = true) ⇒ Swftly
init w/ a swf, through false for the second param if you don’t wanna immediately trigger post-conversion processing
9 10 11 12 |
# File 'lib/swftly.rb', line 9 def initialize( swf_path = '', auto_process = true ) @swf_path = swf_path @auto_process = auto_process end |
Instance Attribute Details
#auto_process ⇒ Object
Returns the value of attribute auto_process.
3 4 5 |
# File 'lib/swftly.rb', line 3 def auto_process @auto_process end |
#converted ⇒ Object (readonly)
Returns the value of attribute converted.
4 5 6 |
# File 'lib/swftly.rb', line 4 def converted @converted end |
#converter_response_code ⇒ Object (readonly)
Returns the value of attribute converter_response_code.
4 5 6 |
# File 'lib/swftly.rb', line 4 def converter_response_code @converter_response_code end |
#fetcher_response_code ⇒ Object (readonly)
Returns the value of attribute fetcher_response_code.
4 5 6 |
# File 'lib/swftly.rb', line 4 def fetcher_response_code @fetcher_response_code end |
#markup ⇒ Object (readonly)
Returns the value of attribute markup.
4 5 6 |
# File 'lib/swftly.rb', line 4 def markup @markup end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
4 5 6 |
# File 'lib/swftly.rb', line 4 def raw @raw end |
#runtime ⇒ Object (readonly)
Returns the value of attribute runtime.
4 5 6 |
# File 'lib/swftly.rb', line 4 def runtime @runtime end |
#swf_path ⇒ Object
Returns the value of attribute swf_path.
3 4 5 |
# File 'lib/swftly.rb', line 3 def swf_path @swf_path end |
Instance Method Details
#process! ⇒ Object
perform and process the second fetching
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/swftly.rb', line 33 def process! return failed unless @converter_response_code == 200 path = URI::extract(@raw).detect { |d| d.match /\/o\// } path += @raw.split('","').detect { |d| d.match '.html' } fetcher = Curl.get(path) @fetcher_response_code = fetcher.response_code @markup = fetcher.body_str @runtime = Runtime.new(@markup) @converted = Converted.new(@markup) end |
#swiff ⇒ Object
post the swf to swiffy and parse/process the results
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/swftly.rb', line 15 def swiff return nil unless @swf_path.instance_of? String file = Curl::PostField.file 'swfFile', @swf_path converter = Curl::Easy.http_post("https://www.google.com/doubleclick/studio/swiffy/upload", file) do |curl| curl.multipart_form_post = true curl.headers["User-Agent"] = "Curl/Ruby" curl.follow_location = true curl. = true end @converter_response_code = converter.response_code @raw = converter.body_str process! if @auto_process end |