Class: Craigslist::API::PostingBlock
- Inherits:
-
Object
- Object
- Craigslist::API::PostingBlock
- Defined in:
- lib/craigslist/api/posting_block.rb
Overview
Remaining prepaid posting blocks for one area/product combination.
Instance Attribute Summary collapse
-
#area ⇒ String
readonly
Area abbreviation, e.g.
-
#product_class ⇒ String
readonly
E.g.
-
#product_name ⇒ String
readonly
E.g.
-
#remaining_posts ⇒ Integer
readonly
Postings still available against this block.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(area:, product_class:, product_name:, remaining_posts:) ⇒ PostingBlock
constructor
A new instance of PostingBlock.
- #inspect ⇒ Object
Constructor Details
#initialize(area:, product_class:, product_name:, remaining_posts:) ⇒ PostingBlock
Returns a new instance of PostingBlock.
19 20 21 22 23 24 25 |
# File 'lib/craigslist/api/posting_block.rb', line 19 def initialize(area:, product_class:, product_name:, remaining_posts:) @area = area @product_class = product_class @product_name = product_name @remaining_posts = remaining_posts.to_i freeze end |
Instance Attribute Details
#area ⇒ String (readonly)
Returns area abbreviation, e.g. "htf".
8 9 10 |
# File 'lib/craigslist/api/posting_block.rb', line 8 def area @area end |
#product_class ⇒ String (readonly)
Returns e.g. "CAR", "JOB".
11 12 13 |
# File 'lib/craigslist/api/posting_block.rb', line 11 def product_class @product_class end |
#product_name ⇒ String (readonly)
Returns e.g. "hartford cars & trucks - by dealer block".
14 15 16 |
# File 'lib/craigslist/api/posting_block.rb', line 14 def product_name @product_name end |
#remaining_posts ⇒ Integer (readonly)
Returns postings still available against this block.
17 18 19 |
# File 'lib/craigslist/api/posting_block.rb', line 17 def remaining_posts @remaining_posts end |
Class Method Details
.from(hash) ⇒ PostingBlock
29 30 31 32 33 34 35 36 |
# File 'lib/craigslist/api/posting_block.rb', line 29 def self.from(hash) new( area: hash["area"], product_class: hash["productClass"], product_name: hash["productName"], remaining_posts: hash["remainingPosts"] ) end |
Instance Method Details
#inspect ⇒ Object
38 39 40 41 |
# File 'lib/craigslist/api/posting_block.rb', line 38 def inspect "#<#{self.class.name} area=#{area.inspect} class=#{product_class.inspect} " \ "remaining=#{remaining_posts}>" end |