Class: Craigslist::API::ImageInfo
- Inherits:
-
Object
- Object
- Craigslist::API::ImageInfo
- Defined in:
- lib/craigslist/api/image_info.rb
Overview
Metadata about an image attached to a live posting.
Instance Attribute Summary collapse
- #filename ⇒ String? readonly
-
#format ⇒ String?
readonly
E.g.
- #height ⇒ Integer? readonly
-
#id ⇒ String
readonly
Craigslist's image id, e.g.
-
#position ⇒ Integer?
readonly
Zero-based position within the posting.
- #width ⇒ Integer? readonly
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id:, filename: nil, format: nil, width: nil, height: nil, position: nil) ⇒ ImageInfo
constructor
A new instance of ImageInfo.
- #inspect ⇒ Object
Constructor Details
#initialize(id:, filename: nil, format: nil, width: nil, height: nil, position: nil) ⇒ ImageInfo
Returns a new instance of ImageInfo.
25 26 27 28 29 30 31 32 33 |
# File 'lib/craigslist/api/image_info.rb', line 25 def initialize(id:, filename: nil, format: nil, width: nil, height: nil, position: nil) @id = id @filename = filename @format = format @width = width @height = height @position = position freeze end |
Instance Attribute Details
#filename ⇒ String? (readonly)
11 12 13 |
# File 'lib/craigslist/api/image_info.rb', line 11 def filename @filename end |
#format ⇒ String? (readonly)
Returns e.g. "JPEG", "GIF", "WEBP".
14 15 16 |
# File 'lib/craigslist/api/image_info.rb', line 14 def format @format end |
#height ⇒ Integer? (readonly)
20 21 22 |
# File 'lib/craigslist/api/image_info.rb', line 20 def height @height end |
#id ⇒ String (readonly)
Returns craigslist's image id, e.g. "4:00101_b1ztTgNtBAU".
8 9 10 |
# File 'lib/craigslist/api/image_info.rb', line 8 def id @id end |
#position ⇒ Integer? (readonly)
Returns zero-based position within the posting.
23 24 25 |
# File 'lib/craigslist/api/image_info.rb', line 23 def position @position end |
#width ⇒ Integer? (readonly)
17 18 19 |
# File 'lib/craigslist/api/image_info.rb', line 17 def width @width end |
Class Method Details
.from(hash) ⇒ ImageInfo
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/craigslist/api/image_info.rb', line 37 def self.from(hash) new( id: hash["id"], filename: hash["filename"], format: hash["format"], width: hash["width"], height: hash["height"], position: hash["position"] ) end |
Instance Method Details
#inspect ⇒ Object
48 49 50 |
# File 'lib/craigslist/api/image_info.rb', line 48 def inspect "#<#{self.class.name} id=#{id.inspect} position=#{position.inspect} #{width}x#{height} #{format}>" end |