Class: FluShot::Vaccine
- Inherits:
-
Object
- Object
- FluShot::Vaccine
- Defined in:
- lib/flu_shot/vaccine.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Class Method Summary collapse
- .find(name) ⇒ Object
- .label(name = nil) ⇒ Object
- .registered ⇒ Object
- .use(name, params = {}) ⇒ Object
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Vaccine
constructor
A new instance of Vaccine.
- #label ⇒ Object
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
#attributes ⇒ Object (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 |
.registered ⇒ Object
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
#label ⇒ Object
53 54 55 |
# File 'lib/flu_shot/vaccine.rb', line 53 def label self.class.label end |