Class: ChemistryKit::Catalyst
- Inherits:
-
Object
- Object
- ChemistryKit::Catalyst
- Defined in:
- lib/chemistrykit/catalyst.rb
Instance Method Summary collapse
- #get_value_for(key) ⇒ Object
-
#initialize(data_file) ⇒ Catalyst
constructor
this class serves as a standard container for data that can be injected into a formula.
- #method_missing(name) ⇒ Object
Constructor Details
#initialize(data_file) ⇒ Catalyst
this class serves as a standard container for data that can be injected into a formula
7 8 9 10 11 12 |
# File 'lib/chemistrykit/catalyst.rb', line 7 def initialize(data_file) @data = {} CSV.foreach(data_file) do | row | @data[row[0].to_sym] = row[1] end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name) ⇒ Object
14 15 16 17 |
# File 'lib/chemistrykit/catalyst.rb', line 14 def method_missing(name) validate_key name @data[name] end |
Instance Method Details
#get_value_for(key) ⇒ Object
19 20 21 22 |
# File 'lib/chemistrykit/catalyst.rb', line 19 def get_value_for(key) validate_key key @data[key.to_sym] end |