Class: Comma::HeaderExtractor

Inherits:
Extractor show all
Defined in:
lib/comma/extractors.rb

Instance Method Summary collapse

Methods inherited from Extractor

#id, #initialize, #results

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



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/comma/extractors.rb', line 23

def method_missing(sym, *args, &block)
  @results << sym.to_s.humanize if args.blank?
  args.each do |arg|
    case arg
    when Hash
      arg.each do |k, v|
        @results << ((v.is_a? String) ? v : v.to_s.humanize)
      end
    when Symbol
      @results << arg.to_s.humanize
    when String
      @results << arg
    else
      raise "Unknown header symbol #{arg.inspect}"
    end
  end
end