Module: ScribdFu::InstanceMethods
- Defined in:
- lib/scribd_fu.rb
Instance Attribute Summary collapse
-
#post_to_scribd ⇒ Object
Returns the value of attribute post_to_scribd.
Class Method Summary collapse
Instance Method Summary collapse
-
#conversion_complete? ⇒ Boolean
Responds true if the conversion is complete – note that this gives no indication as to whether the conversion had an error or was succesful, just that the conversion completed.
-
#conversion_error? ⇒ Boolean
Responds true if there was a conversion error while converting to iPaper.
-
#conversion_processing? ⇒ Boolean
Responds true if the conversion is converting.
-
#conversion_successful? ⇒ Boolean
Responds true if the document has been converted.
-
#destroy_ipaper_document ⇒ Object
Destroys the scribd document for this record.
-
#display_ipaper(options = {}) ⇒ Object
Display the iPaper document in a view.
-
#ipaper_document ⇒ Object
Responds the Scribd::Document associated with this model, or nil if it does not exist.
-
#scribdable? ⇒ Boolean
Checks whether the associated file is convertable to iPaper.
-
#upload_to_scribd ⇒ Object
Upload the associated file to Scribd for iPaper conversion This is called
after_save
and cannot be called earlier, so don’t get any ideas.
Instance Attribute Details
#post_to_scribd ⇒ Object
Returns the value of attribute post_to_scribd.
177 178 179 |
# File 'lib/scribd_fu.rb', line 177 def post_to_scribd @post_to_scribd end |
Class Method Details
.included(base) ⇒ Object
179 180 181 |
# File 'lib/scribd_fu.rb', line 179 def self.included(base) base.extend ClassMethods end |
Instance Method Details
#conversion_complete? ⇒ Boolean
Responds true if the conversion is complete – note that this gives no indication as to whether the conversion had an error or was succesful, just that the conversion completed.
203 204 205 |
# File 'lib/scribd_fu.rb', line 203 def conversion_complete? ipaper_document && ipaper_document.conversion_status != 'PROCESSING' end |
#conversion_error? ⇒ Boolean
Responds true if there was a conversion error while converting to iPaper.
213 214 215 |
# File 'lib/scribd_fu.rb', line 213 def conversion_error? ipaper_document && ipaper_document.conversion_status == 'ERROR' end |
#conversion_processing? ⇒ Boolean
Responds true if the conversion is converting
196 197 198 |
# File 'lib/scribd_fu.rb', line 196 def conversion_processing? !(conversion_complete? || conversion_successful? || conversion_error?) end |
#conversion_successful? ⇒ Boolean
Responds true if the document has been converted.
208 209 210 |
# File 'lib/scribd_fu.rb', line 208 def conversion_successful? ipaper_document && ipaper_document.conversion_status =~ /^DISPLAYABLE|DONE$/ end |
#destroy_ipaper_document ⇒ Object
Destroys the scribd document for this record. This is called before_destroy
223 224 225 |
# File 'lib/scribd_fu.rb', line 223 def destroy_ipaper_document ScribdFu::destroy(ipaper_document) if ipaper_document end |
#display_ipaper(options = {}) ⇒ Object
Display the iPaper document in a view
228 229 230 231 232 233 234 235 236 237 238 |
# File 'lib/scribd_fu.rb', line 228 def display_ipaper( = {}) <<-END <script type="text/javascript" src="http://www.scribd.com/javascripts/view.js"></script> <div id="embedded_flash">#{.delete(:alt)}</div> <script type="text/javascript"> var scribd_doc = scribd.Document.getDoc(#{ipaper_id}, '#{ipaper_access_key}'); #{js_params()} scribd_doc.write("embedded_flash"); </script> END end |
#ipaper_document ⇒ Object
Responds the Scribd::Document associated with this model, or nil if it does not exist.
218 219 220 |
# File 'lib/scribd_fu.rb', line 218 def ipaper_document @document ||= ScribdFu::load_ipaper_document(ipaper_id) end |
#scribdable? ⇒ Boolean
Checks whether the associated file is convertable to iPaper
191 192 193 |
# File 'lib/scribd_fu.rb', line 191 def scribdable? ContentTypes.include?(get_content_type) && ipaper_id.blank? end |