Class: Remarkably::Base::Engine

Inherits:
Object
  • Object
show all
Defined in:
lib/remarkably.rb

Direct Known Subclasses

Engines::CSS, Engines::XML

Instance Method Summary collapse

Constructor Details

#initialize(*args, &block) ⇒ Engine

Returns a new instance of Engine.



12
13
14
15
# File 'lib/remarkably.rb', line 12

def initialize *args, &block
  clear!
  self.instance_eval( &block ) if block_given?
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



27
28
29
# File 'lib/remarkably.rb', line 27

def method_missing(sym, *args, &block)
  missing_method( sym, self, *args, &block )
end

Instance Method Details

#clear!Object



31
32
33
# File 'lib/remarkably.rb', line 31

def clear!
  @output = ''
end

#method!(sym, args, hash, &block) ⇒ Object



35
36
# File 'lib/remarkably.rb', line 35

def method! sym, args, hash, &block
end

#missing_method(sym, context, *args, &block) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/remarkably.rb', line 17

def missing_method(sym, context, *args, &block)
  @context = context
  hash = args.last.is_a?(Hash) ? args.pop : {}
  if methods.index( sym.to_s )
    self.send( sym, args, hash, &block )
  else
    method!(sym, args, hash, &block)
  end
end

#to_sObject



38
39
40
41
42
# File 'lib/remarkably.rb', line 38

def to_s
  result = @output
  clear!
  result
end