Class: Pinterest::Image
- Inherits:
-
Object
- Object
- Pinterest::Image
- Defined in:
- lib/pinterest/models/image.rb
Overview
A object representing a Pinterest image.
Instance Method Summary collapse
-
#as_json(_ = {}) ⇒ Hash
Serialize the object as a Hash that can be serialized as JSON.
-
#initialize(data) ⇒ Pinterest::Board
constructor
Creates a new image object.
-
#size(version) ⇒ Hash
Returns the size of a version of the image.
-
#url(version) ⇒ String
Returns the URL of a version of the image.
-
#versions ⇒ Array
Returns the possible versions of a image.
Constructor Details
#initialize(data) ⇒ Pinterest::Board
Creates a new image object.
13 14 15 |
# File 'lib/pinterest/models/image.rb', line 13 def initialize(data) @data = data end |
Instance Method Details
#as_json(_ = {}) ⇒ Hash
Serialize the object as a Hash that can be serialized as JSON.
45 46 47 |
# File 'lib/pinterest/models/image.rb', line 45 def as_json(_ = {}) @data end |
#size(version) ⇒ Hash
Returns the size of a version of the image.
28 29 30 31 |
# File 'lib/pinterest/models/image.rb', line 28 def size(version) data = @data.fetch(version.to_s) {width: data["width"], height: data["height"]} end |
#url(version) ⇒ String
Returns the URL of a version of the image.
37 38 39 |
# File 'lib/pinterest/models/image.rb', line 37 def url(version) @data.fetch(version.to_s)["url"] end |
#versions ⇒ Array
Returns the possible versions of a image.
20 21 22 |
# File 'lib/pinterest/models/image.rb', line 20 def versions @data.keys end |