class Object

Public Instance Methods

argument(*params) click to toggle source
# File lib/rbuml/dsl.rb, line 58
def argument(*params)
        $method.add_argument RbUMLMethodArgument.new(*params)
end
attribute(*params) click to toggle source
# File lib/rbuml/dsl.rb, line 38
def attribute(*params)
        $current.add_attribute RbUMLAttribute.new(*params)
end
extends(kind) click to toggle source
# File lib/rbuml/dsl.rb, line 28
def extends(kind)
        $current.add_parent kind
end
implements(kind) click to toggle source
# File lib/rbuml/dsl.rb, line 33
def implements(kind)
        $current.add_interface kind
end
kind(k) click to toggle source
# File lib/rbuml/dsl.rb, line 18
def kind(k)
        $current.kind = k
end
method(*params, &block) click to toggle source
# File lib/rbuml/dsl.rb, line 48
def method(*params, &block)
        $method = RbUMLMethod.new(*params)
        if block_given?
                block.call $method
        end
        $current.add_method $method
        $method = nil
end
note(text) click to toggle source
# File lib/rbuml/dsl.rb, line 23
def note(text)
        $current.add_note RbUMLNote.new(text)
end
rbuml_dot_render(classes, filename, format=:png) click to toggle source
# File lib/rbuml/dot.rb, line 6
def rbuml_dot_render(classes, filename, format=:png)
        g = GraphViz.new(:G, :type => :digraph, :ratio => :compress)
        
        classes.each do |name, cls|
                g.add_nodes(cls.name, :label => cls.dot_label, :shape => "record")
        end
        
        classes.each do |name, cls|
                cls.notes.each_with_index do |note,i|
                        g.add_nodes("note#{cls.name}#{i}", :label => note.dot_label, :shape => :note)
                        g.add_edges(cls.name, "note#{cls.name}#{i}", :dir => :none)
                end
        end
        
        classes.each do |name, cls|
                cls.interfaces.each do |inter|
                        g.add_edges(cls.name, inter, :arrowhead => :empty)
                end
                
                cls.parents.each do |parent|
                        g.add_edges(cls.name, parent, :arrowhead => :empty)
                end
                
                cls.relationships.each do |rel|
                        g.add_edges(cls.name, rel.kind, :label => rel.dot_label, :dir => :both, :arrowhead => :none, :arrowtail => :odiamond, :headlabel => rel.head_label)
                end
        end
        
        g.output(format => filename)
        puts "saved " + filename
end
relationship(*params) click to toggle source
# File lib/rbuml/dsl.rb, line 43
def relationship(*params)
        $current.add_relationship RbUMLRelationship.new(*params)
end
save(filename, format=:png) click to toggle source
# File lib/rbuml/dsl.rb, line 63
def save(filename, format=:png)
        rbuml_dot_render $known_classes, filename, format
end
uml_class(*params, &block) click to toggle source
# File lib/rbuml/dsl.rb, line 8
def uml_class(*params, &block)
        $current = RbUMLClass.new(*params)
        if block_given?
                block.call $current
        end
        $known_classes[$current.name] = $current
        $current = nil
end