Class: Remarkably::Engines::XML

Inherits:
Base::Engine show all
Defined in:
lib/remarkably/engines/xml.rb

Direct Known Subclasses

HTML

Instance Attribute Summary

Attributes inherited from Base::Engine

#remarkably_engine

Instance Method Summary collapse

Methods inherited from Base::Engine

#clear!, #initialize, #method_missing, #missing_method, #to_s

Constructor Details

This class inherits a constructor from Remarkably::Base::Engine

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Remarkably::Base::Engine

Instance Method Details

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



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/remarkably/engines/xml.rb', line 7

def method! sym, args, hash, &block
  sym = sym.to_s.downcase

  tag_attributes =
    hash.inject([]){|s,(k,v)| s << %{#{k.to_s.downcase}="#{v}"} }

  @output << ( ["<#{sym}"] +  tag_attributes).join(' ')

  if block_given? or not args.empty?
    @output << ">"
    block.call if block_given?
    @output << "#{args.join}</#{sym}>"
  else
    @output << "/>"
  end

  self
end

#text(args, hash) ⇒ Object



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

def text args, hash
  @output << args.join
  self
end