Class: CsvReader::Base
- Inherits:
-
Object
- Object
- CsvReader::Base
- Defined in:
- lib/csv_reader/base.rb
Instance Method Summary collapse
-
#initialize(csv_file) ⇒ Base
constructor
A new instance of Base.
- #method_missing(*args) ⇒ Object
Constructor Details
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*args) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/csv_reader/base.rb', line 8 def method_missing(*args) method_name = args[0] value_to_find = args[1] arr = method_name.to_s.split('find_by_') if arr.first == "" field_name = arr[1] if @parser.headers.include?(field_name) CsvReader::Finder.new(@parser, field_name, value_to_find).find else raise NoMethodError end else raise NoMethodError end end |