Class: Comma::DataExtractor
- Defined in:
- lib/comma/extractors.rb
Instance Method Summary collapse
Methods inherited from Extractor
Constructor Details
This class inherits a constructor from Comma::Extractor
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/comma/extractors.rb', line 45 def method_missing(sym, *args, &block) @results << @instance.send(sym).to_s if args.blank? args.each do |arg| case arg when Hash arg.each do |k, v| @results << (@instance.send(sym).nil? ? '' : @instance.send(sym).send(k).to_s ) end when Symbol @results << ( @instance.send(sym).nil? ? '' : @instance.send(sym).send(arg).to_s ) when String @results << @instance.send(sym).to_s else raise "Unknown data symbol #{arg.inspect}" end end end |