Class: FluShot::Vaccine

Inherits:
Object
  • Object
show all
Defined in:
lib/flu_shot/vaccine.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Vaccine

Returns a new instance of Vaccine.



26
27
28
# File 'lib/flu_shot/vaccine.rb', line 26

def initialize(attributes = {})
  @attributes = attributes
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



24
25
26
# File 'lib/flu_shot/vaccine.rb', line 24

def attributes
  @attributes
end

Class Method Details

.find(name) ⇒ Object



45
46
47
# File 'lib/flu_shot/vaccine.rb', line 45

def self.find(name)
  self.vaccines[name]
end

.label(name = nil) ⇒ Object



30
31
32
33
34
35
36
37
38
39
# File 'lib/flu_shot/vaccine.rb', line 30

def self.label(name = nil)
  if name.nil?
    if defined?(@vaccine_name)
      @vaccine_name
    end || :unknown
  else
    @vaccine_name = name
    vaccines[name] = self
  end
end

.registeredObject



41
42
43
# File 'lib/flu_shot/vaccine.rb', line 41

def self.registered
  self.vaccines.keys
end

.use(name, params = {}) ⇒ Object



49
50
51
# File 'lib/flu_shot/vaccine.rb', line 49

def self.use(name, params = {})
  find(name).new(params)
end

Instance Method Details

#labelObject



53
54
55
# File 'lib/flu_shot/vaccine.rb', line 53

def label
  self.class.label
end