Class: MotionBlender::Collector
- Inherits:
-
Object
- Object
- MotionBlender::Collector
- Defined in:
- lib/motion_blender/collector.rb
Instance Attribute Summary collapse
-
#interpreters ⇒ Object
Returns the value of attribute interpreters.
-
#requires ⇒ Object
Returns the value of attribute requires.
-
#source ⇒ Object
Returns the value of attribute source.
Class Method Summary collapse
- .acceptable?(source) ⇒ Boolean
- .interpreters ⇒ Object
- .refinements ⇒ Object
- .register(interpreter) ⇒ Object
- .requirable?(source) ⇒ Boolean
Instance Method Summary collapse
- #collect_requires ⇒ Object
-
#initialize(source) ⇒ Collector
constructor
A new instance of Collector.
Constructor Details
#initialize(source) ⇒ Collector
Returns a new instance of Collector.
34 35 36 37 38 39 40 |
# File 'lib/motion_blender/collector.rb', line 34 def initialize source @source = source @interpreters = self.class.interpreters.map do |interpreter| [interpreter.key, interpreter.new(self)] end.to_h @requires = [] end |
Instance Attribute Details
#interpreters ⇒ Object
Returns the value of attribute interpreters.
32 33 34 |
# File 'lib/motion_blender/collector.rb', line 32 def interpreters @interpreters end |
#requires ⇒ Object
Returns the value of attribute requires.
32 33 34 |
# File 'lib/motion_blender/collector.rb', line 32 def requires @requires end |
#source ⇒ Object
Returns the value of attribute source.
32 33 34 |
# File 'lib/motion_blender/collector.rb', line 32 def source @source end |
Class Method Details
.acceptable?(source) ⇒ Boolean
20 21 22 23 |
# File 'lib/motion_blender/collector.rb', line 20 def acceptable? source !source.type.block? || (source.children.first.code != 'MotionBlender.raketime') end |
.interpreters ⇒ Object
7 8 9 |
# File 'lib/motion_blender/collector.rb', line 7 def interpreters @interpreters ||= [] end |
.refinements ⇒ Object
25 26 27 28 29 |
# File 'lib/motion_blender/collector.rb', line 25 def refinements @refinements ||= Hash.new do |hash, key| hash[key] = Module.new { key.prepend self } end end |
.register(interpreter) ⇒ Object
11 12 13 14 |
# File 'lib/motion_blender/collector.rb', line 11 def register interpreter interpreters << interpreter interpreter end |
.requirable?(source) ⇒ Boolean
16 17 18 |
# File 'lib/motion_blender/collector.rb', line 16 def requirable? source interpreters.each_with_object(source).any?(&:requirable?) end |
Instance Method Details
#collect_requires ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/motion_blender/collector.rb', line 42 def collect_requires obj = evaluating_object if obj.is_a? Module with_refinements do obj.module_eval(source.code, source.file, source.line) end else with_refinements do obj.instance_eval(source.code, source.file, source.line) end end requires end |