Class: StellingBanjos::Banjos

Inherits:
Object
  • Object
show all
Defined in:
lib/stelling_banjos/banjos.rb

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, price, link, sold_out) ⇒ Banjos

Returns a new instance of Banjos.



6
7
8
9
10
11
12
# File 'lib/stelling_banjos/banjos.rb', line 6

def initialize(name, price, link, sold_out)
  @name = name
  @price = price
  @link = link
  @sold_out = sold_out
  @@all << self
end

Instance Attribute Details

Returns the value of attribute link.



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

def link
  @link
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#priceObject

Returns the value of attribute price.



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

def price
  @price
end

#sold_outObject

Returns the value of attribute sold_out.



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

def sold_out
  @sold_out
end

Class Method Details

.allObject



31
32
33
# File 'lib/stelling_banjos/banjos.rb', line 31

def self.all
  @@all
end

.create_from_catalog(array) ⇒ Object



14
15
16
17
18
# File 'lib/stelling_banjos/banjos.rb', line 14

def self.create_from_catalog(array)
  array.each do |hash|
    self.new(hash[:name], hash[:price], hash[:link], hash[:sold_out])
  end
end

Instance Method Details

#sold_out?Boolean

Returns:

  • (Boolean)


20
21
22
23
24
25
26
27
28
29
# File 'lib/stelling_banjos/banjos.rb', line 20

def sold_out?
  case @sold_out
  when "Yes"
    return true
  when "No"
    return false
  else
    return false
  end
end