Class: EimXML::OpenDSL

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

Direct Known Subclasses

XHTML::OpenDSL

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ OpenDSL

Returns a new instance of OpenDSL.

Yields:

  • (_self)

Yield Parameters:



96
97
98
99
# File 'lib/eim_xml/dsl.rb', line 96

def initialize
  @_container = nil
  yield(self) if block_given?
end

Class Method Details

.registerObject



92
93
94
# File 'lib/eim_xml/dsl.rb', line 92

def self.register(*)
  register_base(self, binding, *)
end

.register_base(_dsl, binding, *args) ⇒ Object



81
82
83
84
85
86
87
88
89
90
# File 'lib/eim_xml/dsl.rb', line 81

def self.register_base(_dsl, binding, *args)
  args.each do |klass, name|
    name ||= klass.name.downcase[/(?:.*::)?(.*)$/, 1]

    # rubocop:disable Security/Eval, Layout/LineLength
    eval("def #{name}(*a, &p);_build(#{klass}, *a, &p);end", binding, __FILE__, __LINE__) # def element(*a, &p);_build(Element, *a, &p);end
    eval("def self.#{name}(*a, &p);self.new.#{name}(*a, &p);end", binding, __FILE__, __LINE__) # def self.element(*a, &p);self.new.element(*a, &p);end
    # rubocop:enable Security/Eval, Layout/LineLength
  end
end

Instance Method Details

#add(content) ⇒ Object Also known as: <<



101
102
103
# File 'lib/eim_xml/dsl.rb', line 101

def add(content)
  @_container.add(content)
end

#containerObject



106
107
108
# File 'lib/eim_xml/dsl.rb', line 106

def container
  @_container
end