Class: Postful::SimpleDocument
- Defined in:
- lib/postful/simple_document.rb
Instance Attribute Summary collapse
-
#attachment_name ⇒ Object
Returns the value of attribute attachment_name.
-
#content ⇒ Object
Returns the value of attribute content.
-
#format ⇒ Object
Returns the value of attribute format.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
Methods inherited from Document
Constructor Details
This class inherits a constructor from Postful::Document
Instance Attribute Details
#attachment_name ⇒ Object
Returns the value of attribute attachment_name.
8 9 10 |
# File 'lib/postful/simple_document.rb', line 8 def @attachment_name end |
#content ⇒ Object
Returns the value of attribute content.
7 8 9 |
# File 'lib/postful/simple_document.rb', line 7 def content @content end |
#format ⇒ Object
Returns the value of attribute format.
6 7 8 |
# File 'lib/postful/simple_document.rb', line 6 def format @format end |
#url ⇒ Object
Returns the value of attribute url.
9 10 11 |
# File 'lib/postful/simple_document.rb', line 9 def url @url end |
Instance Method Details
#build_request(builder) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/postful/simple_document.rb', line 11 def build_request(builder) builder.document do builder.type format builder. if builder.url url if url end end |
#requires_upload? ⇒ Boolean
19 20 21 |
# File 'lib/postful/simple_document.rb', line 19 def requires_upload? true if !url end |
#upload ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/postful/simple_document.rb', line 23 def upload if requires_upload? headers = { 'Content-Type' => 'application/octet-stream', 'Content-Length' => content.size.to_s } response = post_request_on_path('/service/upload', content, @email, @password, headers) if response.is_a?(Net::HTTPOK) && response.body =~ /<id>(.*)<\/id>/ self. = $1 else # raise stuff end end end |