Class: PhoneSites::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/phone_sites/base.rb

Direct Known Subclasses

Manufacturer, PhoneModel

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Base

Returns a new instance of Base.


4
5
6
7
8
# File 'lib/phone_sites/base.rb', line 4

def initialize(data)
  parseable_fields.each do |name|
    public_send("#{name}=", parse(data, name))
  end
end

Class Method Details

.parseable_attributes(*names) ⇒ Object


14
15
16
17
# File 'lib/phone_sites/base.rb', line 14

def self.parseable_attributes(*names)
  names.each { |name| attr_accessor name }
  define_method("parseable_fields") { names }
end

Instance Method Details

#parse(_, _) ⇒ Object

Raises:

  • (NotImplementedError)

10
11
12
# File 'lib/phone_sites/base.rb', line 10

def parse(_, _)
  raise NotImplementedError
end