Class: ODF::Container
- Inherits:
-
Object
show all
- Defined in:
- lib/odf/container.rb
Class Method Summary
collapse
Class Method Details
.contains(*stuffs_array) ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/odf/container.rb', line 25
def self.contains(*stuffs_array)
stuffs_array.map {|sym| sym.to_s}.each do |stuffs|
stuff = stuffs.to_s.singularize
stuff_class = eval(stuff.capitalize)
self.class_eval "
def #{stuffs}
@#{stuffs} ||= []
end"
self.class_eval "
def #{stuff}(*args)
c = #{stuff_class}.new(*args)
yield c if block_given?
#{stuffs} << c
c
end"
self.class_eval "
def #{stuffs}_xml
#{stuffs}.map {|c| c.xml}.join
end"
end
end
|
.create(*args) {|container| ... } ⇒ Object
50
51
52
53
54
|
# File 'lib/odf/container.rb', line 50
def self.create(*args)
container = self.new(*args)
yield container if block_given?
container.xml
end
|