Class: Epubify::Download
- Inherits:
-
Object
- Object
- Epubify::Download
- Defined in:
- lib/shelf/download.rb
Instance Attribute Summary collapse
-
#content_type ⇒ Object
Returns the value of attribute content_type.
-
#id ⇒ Object
Returns the value of attribute id.
-
#item_id ⇒ Object
Returns the value of attribute item_id.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #destroy ⇒ Object
- #from_hash(h) ⇒ Object
-
#initialize(h = nil) {|_self| ... } ⇒ Download
constructor
A new instance of Download.
- #item ⇒ Object
- #item=(v) ⇒ Object
- #save ⇒ Object
Constructor Details
#initialize(h = nil) {|_self| ... } ⇒ Download
Returns a new instance of Download.
8 9 10 11 12 13 |
# File 'lib/shelf/download.rb', line 8 def initialize h = nil, &block content_type = "application/epub+zip" from_hash h if h yield self if block end |
Instance Attribute Details
#content_type ⇒ Object
Returns the value of attribute content_type.
6 7 8 |
# File 'lib/shelf/download.rb', line 6 def content_type @content_type end |
#id ⇒ Object
Returns the value of attribute id.
6 7 8 |
# File 'lib/shelf/download.rb', line 6 def id @id end |
#item_id ⇒ Object
Returns the value of attribute item_id.
6 7 8 |
# File 'lib/shelf/download.rb', line 6 def item_id @item_id end |
#url ⇒ Object
Returns the value of attribute url.
6 7 8 |
# File 'lib/shelf/download.rb', line 6 def url @url end |
Class Method Details
Instance Method Details
#destroy ⇒ Object
45 46 47 |
# File 'lib/shelf/download.rb', line 45 def destroy ShelfApi.destroy_download(id) if id end |
#from_hash(h) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/shelf/download.rb', line 16 def from_hash h self.id = h["id"] self.item_id = h["item_id"] self.content_type = h["content_type"] self.url = h["url"] end |
#item ⇒ Object
30 31 32 |
# File 'lib/shelf/download.rb', line 30 def item @item end |
#item=(v) ⇒ Object
24 25 26 27 |
# File 'lib/shelf/download.rb', line 24 def item= v @item = v item_id = v.id end |
#save ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/shelf/download.rb', line 50 def save @query = { :download => { :item_id => item_id, :content_type => content_type, :url => url } } if id res = ShelfApi.update_download(id, @query) else res = ShelfApi.create_download(@query) from_hash res["download"] end res end |