Class: Craigslist::API::Category
- Inherits:
-
Object
- Object
- Craigslist::API::Category
- Defined in:
- lib/craigslist/api/category.rb
Overview
A craigslist posting category, as published by the public reference service.
Constant Summary collapse
- UNSUPPORTED =
Categories the bulk posting interface explicitly does not support. Submitting to one of these is documented as something not to do.
%w[sbw rew swp sub reo prk hou sha].freeze
Instance Attribute Summary collapse
-
#abbreviation ⇒ Object
readonly
Returns the value of attribute abbreviation.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(abbreviation:, description: nil, type: nil, id: nil) ⇒ Category
constructor
A new instance of Category.
- #inspect ⇒ Object
- #to_s ⇒ Object
-
#unsupported? ⇒ Boolean
Whether bulk posting to this category is disallowed.
Constructor Details
#initialize(abbreviation:, description: nil, type: nil, id: nil) ⇒ Category
Returns a new instance of Category.
14 15 16 17 18 19 20 |
# File 'lib/craigslist/api/category.rb', line 14 def initialize(abbreviation:, description: nil, type: nil, id: nil) @abbreviation = abbreviation @description = description @type = type @id = id freeze end |
Instance Attribute Details
#abbreviation ⇒ Object (readonly)
Returns the value of attribute abbreviation.
12 13 14 |
# File 'lib/craigslist/api/category.rb', line 12 def abbreviation @abbreviation end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
12 13 14 |
# File 'lib/craigslist/api/category.rb', line 12 def description @description end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
12 13 14 |
# File 'lib/craigslist/api/category.rb', line 12 def id @id end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
12 13 14 |
# File 'lib/craigslist/api/category.rb', line 12 def type @type end |
Class Method Details
.from(hash) ⇒ Category
24 25 26 27 28 29 30 31 |
# File 'lib/craigslist/api/category.rb', line 24 def self.from(hash) new( abbreviation: hash["Abbreviation"], description: hash["Description"], type: hash["Type"], id: hash["CategoryID"] ) end |
Instance Method Details
#inspect ⇒ Object
42 43 44 |
# File 'lib/craigslist/api/category.rb', line 42 def inspect "#<#{self.class.name} #{abbreviation.inspect} #{description.inspect} type=#{type.inspect}>" end |
#to_s ⇒ Object
38 39 40 |
# File 'lib/craigslist/api/category.rb', line 38 def to_s abbreviation.to_s end |
#unsupported? ⇒ Boolean
Returns whether bulk posting to this category is disallowed.
34 35 36 |
# File 'lib/craigslist/api/category.rb', line 34 def unsupported? UNSUPPORTED.include?(abbreviation) end |