class Mscgen::Chart
Constants
- MSC_TEMPLATE
Attributes
entities[R]
array of Mscgen::Entity
messages[R]
array of messages
witdh[RW]
sequence chart width
Public Class Methods
new(width=nil)
click to toggle source
# File lib/mscgen/chart.rb, line 15 def initialize(width=nil) @entities = [] @messages = [] @width = width end
Public Instance Methods
add_entity(name)
click to toggle source
add entity to chart
# File lib/mscgen/chart.rb, line 22 def add_entity(name) entity = Entity.new(name) @entities << entity return entity end
add_message(from_or_msg, to=nil, label=nil, param=nil)
click to toggle source
add messages to chart..
- from_or_msg
-
from entity or
Message
instance - to
-
to entity
- label
-
message label string
- param
-
message parameters
# File lib/mscgen/chart.rb, line 43 def add_message(from_or_msg, to=nil, label=nil, param=nil) if to.nil? and label.nil? and param.nil? msg = from_or_msg raise ArgumentError unless msg.respond_to?(:to_msc) else msg = Mscgen::Message.new(from_or_msg, to, label, param) end @messages << msg msg end
find_or_add_entity(name)
click to toggle source
find entity from chart or add entity to chart
# File lib/mscgen/chart.rb, line 29 def find_or_add_entity(name) entity = @entities.find {|e| e.label == name.to_s } if entity.nil? self.add_entity(name) else entity end end
to_img(filename, type=nil)
click to toggle source
execute mscgen command
# File lib/mscgen/chart.rb, line 64 def to_img(filename, type=nil) text = to_msc() execute_msc_cmd(text, filename, type) text end
to_msc()
click to toggle source
return mscgen format script
# File lib/mscgen/chart.rb, line 55 def to_msc opt = get_opt ent_text = @entities.map{|e| e.to_msc }.join(', ') msg_text = @messages.map{|m| m.to_msc }.join(";\n ") return MSC_TEMPLATE % [opt, ent_text, msg_text] end