Class: VitaminedGems::VitaminExtractor

Inherits:
Object
  • Object
show all
Defined in:
lib/vitamined-gems.rb

Instance Method Summary collapse

Constructor Details

#initialize(from = nil, &block) ⇒ VitaminExtractor

Returns a new instance of VitaminExtractor.



57
58
59
60
# File 'lib/vitamined-gems.rb', line 57

def initialize(from = nil, &block)
  @from = from || block
  @extracted_vitamins = {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(symbol, *args, &block) ⇒ Object



71
72
73
# File 'lib/vitamined-gems.rb', line 71

def method_missing(symbol, *args, &block)
  @extracted_vitamins[symbol] = block_given? ? block : args.first
end

Instance Method Details

#extractObject



62
63
64
65
66
67
68
69
# File 'lib/vitamined-gems.rb', line 62

def extract
   if @from.is_a? Proc
     instance_eval(&@from) 
   else 
     instance_eval(@from)
   end
   @extracted_vitamins
end