Class: Item

Inherits:
Object
  • Object
show all
Extended by:
Concerns::Mergable, Concerns::Searchable
Defined in:
lib/item.rb

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Concerns::Searchable

get_link_from_key, get_subcategory_info, items_in_price_range, items_with_price, search_by_category, search_by_pid, search_by_type, search_items

Methods included from Concerns::Mergable

merge_item, merge_price_manager_attr

Constructor Details

#initialize(item_hash) ⇒ Item

Returns a new instance of Item.



8
9
10
11
# File 'lib/item.rb', line 8

def initialize(item_hash)
  item_hash.each{|key,value| self.send("#{key}=", value)}
  @@all << self if @@all.none?{|item| item.pid == self.pid}
end

Instance Attribute Details

#categoryObject

Returns the value of attribute category.



2
3
4
# File 'lib/item.rb', line 2

def category
  @category
end

#conditionObject

Returns the value of attribute condition.



2
3
4
# File 'lib/item.rb', line 2

def condition
  @condition
end

#cylindersObject

Returns the value of attribute cylinders.



2
3
4
# File 'lib/item.rb', line 2

def cylinders
  @cylinders
end

#driveObject

Returns the value of attribute drive.



2
3
4
# File 'lib/item.rb', line 2

def drive
  @drive
end

#fuelObject

Returns the value of attribute fuel.



2
3
4
# File 'lib/item.rb', line 2

def fuel
  @fuel
end

Returns the value of attribute link.



2
3
4
# File 'lib/item.rb', line 2

def link
  @link
end

#locationObject

Returns the value of attribute location.



2
3
4
# File 'lib/item.rb', line 2

def location
  @location
end

#makeObject

Returns the value of attribute make.



2
3
4
# File 'lib/item.rb', line 2

def make
  @make
end

#modelObject

Returns the value of attribute model.



2
3
4
# File 'lib/item.rb', line 2

def model
  @model
end

#numberObject

Returns the value of attribute number.



2
3
4
# File 'lib/item.rb', line 2

def number
  @number
end

#odometerObject

Returns the value of attribute odometer.



2
3
4
# File 'lib/item.rb', line 2

def odometer
  @odometer
end

#other_adsObject

Returns the value of attribute other_ads.



2
3
4
# File 'lib/item.rb', line 2

def other_ads
  @other_ads
end

#paintObject

Returns the value of attribute paint.



2
3
4
# File 'lib/item.rb', line 2

def paint
  @paint
end

#pidObject

Returns the value of attribute pid.



2
3
4
# File 'lib/item.rb', line 2

def pid
  @pid
end

#postingbodyObject

Returns the value of attribute postingbody.



2
3
4
# File 'lib/item.rb', line 2

def postingbody
  @postingbody
end

#priceObject

Returns the value of attribute price.



2
3
4
# File 'lib/item.rb', line 2

def price
  @price
end

#sizeObject

Returns the value of attribute size.



2
3
4
# File 'lib/item.rb', line 2

def size
  @size
end

#timeagoObject

Returns the value of attribute timeago.



2
3
4
# File 'lib/item.rb', line 2

def timeago
  @timeago
end

#titleObject

Returns the value of attribute title.



2
3
4
# File 'lib/item.rb', line 2

def title
  @title
end

#transmissionObject

Returns the value of attribute transmission.



2
3
4
# File 'lib/item.rb', line 2

def transmission
  @transmission
end

#typeObject

Returns the value of attribute type.



2
3
4
# File 'lib/item.rb', line 2

def type
  @type
end

#urlObject

Returns the value of attribute url.



2
3
4
# File 'lib/item.rb', line 2

def url
  @url
end

#venueObject

Returns the value of attribute venue.



2
3
4
# File 'lib/item.rb', line 2

def venue
  @venue
end

#venue_dateObject

Returns the value of attribute venue_date.



2
3
4
# File 'lib/item.rb', line 2

def venue_date
  @venue_date
end

#VINObject

Returns the value of attribute VIN.



2
3
4
# File 'lib/item.rb', line 2

def VIN
  @VIN
end

#yearObject

Returns the value of attribute year.



2
3
4
# File 'lib/item.rb', line 2

def year
  @year
end

Class Method Details

.allObject



17
18
19
# File 'lib/item.rb', line 17

def self.all
  @@all
end

.create_from_collection(site_hash) ⇒ Object



13
14
15
# File 'lib/item.rb', line 13

def self.create_from_collection(site_hash)
  site_hash.each{|hash| Item.new(hash)}
end