Sha256: e06633dc5d4c220e1c7ebc443958eb79efe179f2a451348f5d8782ca4104797a

Contents?: true

Size: 893 Bytes

Versions: 1

Compression:

Stored size: 893 Bytes

Contents

require_relative '../concerns/helper_methods.rb'

class SmartphoneFinder::Brand
    include HelperMethods
    extend HelperMethods
    @@all=[]
    attr_accessor :name ,:url ,:devices
	def initialize(name , url)
		@name=name 
		@url= url
		@devices=[]
	    if ! obj_exist?
		  @@all.push(self)
	    end
    end
    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
    def self.all
	   @@all 
     end

    def add_device(device)
      if !self.devices.detect{|obj| obj.name == device.name}
        devices.push(device)
      end
    end
	def self.list_brands
		self.list_all(self.all.collect { |obj| obj.name  })	
	end
	def list_devices
	    self.list_all(self.devices.collect { |obj| obj.name  })
	end
	
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
smartphone_finder-cli-1.1.0 lib/smartphone_finder/brand.rb