class MacroHub

Attributes

macros[R]

Public Class Methods

new(obj=nil) click to toggle source
# File lib/macrohub.rb, line 509
def initialize(obj=nil)
  
  if obj then
    
    s, _ = RXFHelper.read(obj)    
    
    if  s[0] == '<'
      import_xml(s)
    else        
      import_xml(RowX.new(s.gsub(/^#.*/,'')).to_xml)
    end
    
  else

    @macros = []

  end
end

Public Instance Methods

import_xml(raws) click to toggle source
# File lib/macrohub.rb, line 528
def import_xml(raws)
 
  s = RXFHelper.read(raws).first
  puts 's: ' + s.inspect if $debug
  doc = Rexle.new(s)
  puts 'after doc' if $debug
  
  @macros = doc.root.xpath('item').map do |node|
        
    macro = Macro.new node.text('macro')
    macro.import_xml(node)
    macro
    
  end

end
to_doc() click to toggle source
# File lib/macrohub.rb, line 545
def to_doc()
  
  doc = Rexle.new('<macros/>')      
  
  @macros.each do |macro|  
    puts 'macro: ' + macro.inspect if $debug
    doc.root.add macro.to_node
  end
  
  return doc
  
end
to_rowx() click to toggle source
# File lib/macrohub.rb, line 558
def to_rowx()
  
  s = ''
  s += "title: %s\n%s\n\n" % [@title, '-' * 50] if @title
  s += @macros.collect(&:to_rowx).join("\n\n#{'-'*50}\n\n")
  
end
Also aliased as: to_s
to_s()
Alias for: to_rowx
to_xml() click to toggle source
# File lib/macrohub.rb, line 568
def to_xml()
  to_doc.xml pretty: true
end