class Classifieds::Seller

Constants

SUMMARY_COL_FORMATS

A seller is uniquely identified by name + location + phone

Attributes

location[R]
name[R]
phone[RW]

Public Class Methods

clear() click to toggle source

Empty list of created objects

# File lib/classifieds/seller.rb, line 21
def self.clear
  all.clear
end
find_or_create(name, location, phone) click to toggle source

Returns the specified seller, or creates a new one if not found in @@all

# File lib/classifieds/seller.rb, line 26
def self.find_or_create(name, location, phone)
  (seller = find_seller(name, location, phone)) != nil ? seller : new(name, location, phone)
end
find_seller(name, location, phone) click to toggle source

Returns the specified seller from @all or nil if not found

# File lib/classifieds/seller.rb, line 31
def self.find_seller(name, location, phone)
  all.find { |seller| seller.name == name && seller.location == location && seller.phone == phone }
end
new(name, location, phone) click to toggle source
# File lib/classifieds/seller.rb, line 13
def initialize(name, location, phone)
  @name = name
  @location = location
  @phone = phone
  Classifieds::Seller.all << self
end
summary_header() click to toggle source

Return the summary listing summary title row

# File lib/classifieds/seller.rb, line 41
def self.summary_header
  Classifieds::Listing.format_cols(['Seller', 'Location'], SUMMARY_COL_FORMATS)
end

Private Class Methods

all() click to toggle source

Returns array of all sellers

# File lib/classifieds/seller.rb, line 49
def self.all
  @@all_sellers
end

Public Instance Methods

summary_detail() click to toggle source

Return a summary listing detail row

# File lib/classifieds/seller.rb, line 36
def summary_detail
  Classifieds::Listing.format_cols([@name, @location], SUMMARY_COL_FORMATS)
end