class SmartphoneFinder::Brand
Attributes
devices[RW]
name[RW]
url[RW]
Public Class Methods
all()
click to toggle source
# File lib/smartphone_finder/brand.rb, line 24 def self.all @@all end
find_by_name(brand_name)
click to toggle source
# File lib/smartphone_finder/brand.rb, line 16 def self.find_by_name(brand_name) self.all.each do |b| if b.name.downcase==brand_name.downcase return b end end return SmartphoneFinder::Brand.new(brand_name,nil) end
list_brands()
click to toggle source
# File lib/smartphone_finder/brand.rb, line 33 def self.list_brands self.list_all(self.all.collect { |obj| obj.name }) end
new(name , url)
click to toggle source
# File lib/smartphone_finder/brand.rb, line 8 def initialize(name , url) @name=name @url= url @devices=[] if ! obj_exist? @@all.push(self) end end
Public Instance Methods
add_device(device)
click to toggle source
# File lib/smartphone_finder/brand.rb, line 28 def add_device(device) if !self.devices.detect{|obj| obj.name == device.name} devices.push(device) end end
list_devices()
click to toggle source
# File lib/smartphone_finder/brand.rb, line 36 def list_devices self.list_all(self.devices.collect { |obj| obj.name }) end