Class: Gumroad::Link
- Inherits:
-
Object
- Object
- Gumroad::Link
- Defined in:
- lib/gumroad/link.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#id ⇒ Object
Returns the value of attribute id.
-
#json ⇒ Object
readonly
Returns the value of attribute json.
-
#name ⇒ Object
Returns the value of attribute name.
-
#price ⇒ Object
Returns the value of attribute price.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #destroy ⇒ Object
-
#initialize(session, json) ⇒ Link
constructor
A new instance of Link.
- #save ⇒ Object
Constructor Details
#initialize(session, json) ⇒ Link
Returns a new instance of Link.
6 7 8 9 10 11 |
# File 'lib/gumroad/link.rb', line 6 def initialize(session, json) @session = session [:id, :name, :url, :description, :price].each do |attribute| instance_variable_set(:"@#{attribute}", json[attribute.to_s]) end end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
4 5 6 |
# File 'lib/gumroad/link.rb', line 4 def description @description end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/gumroad/link.rb', line 4 def id @id end |
#json ⇒ Object (readonly)
Returns the value of attribute json.
3 4 5 |
# File 'lib/gumroad/link.rb', line 3 def json @json end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/gumroad/link.rb', line 4 def name @name end |
#price ⇒ Object
Returns the value of attribute price.
4 5 6 |
# File 'lib/gumroad/link.rb', line 4 def price @price end |
#url ⇒ Object
Returns the value of attribute url.
4 5 6 |
# File 'lib/gumroad/link.rb', line 4 def url @url end |
Instance Method Details
#destroy ⇒ Object
19 20 21 |
# File 'lib/gumroad/link.rb', line 19 def destroy @session.delete("/links/#{id}") end |
#save ⇒ Object
13 14 15 16 17 |
# File 'lib/gumroad/link.rb', line 13 def save params = {name: name, url: url, description: description, price: price} json = @session.post("/links", params)['link'] self end |