Class: Mscgen::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/mscgen/message.rb

Defined Under Namespace

Classes: UnknownAllowType

Constant Summary collapse

ALLOW_TYPE =

acceptable allow type definition

{
  :messege => "->",
  :method => "=>",
  :method_return => ">>",
  :callback => "=>>",
  :emph_message => ":>",
  :lost_message => "-x",
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(from, to, label = nil, options = {}) ⇒ Message

from

a entity which message from

to

a entity which message to

label

message string

options

supports :type, :linecolor, :textcolor attributes

Raises:

  • (ArgumentError)


22
23
24
25
26
27
28
29
# File 'lib/mscgen/message.rb', line 22

def initialize(from, to, label=nil, options={})
  @from = from
  @to = to
  @label = Mscgen.escape(label.to_s) unless label.nil?
  @options = (options or {})
  raise ArgumentError unless @options.kind_of?(Hash)
  raise UnknownAllowType unless ALLOW_TYPE.has_key?(@options.fetch(:type, :method))
end

Instance Attribute Details

#fromObject (readonly)

Returns the value of attribute from.



16
17
18
# File 'lib/mscgen/message.rb', line 16

def from
  @from
end

#labelObject (readonly)

Returns the value of attribute label.



16
17
18
# File 'lib/mscgen/message.rb', line 16

def label
  @label
end

#toObject (readonly)

Returns the value of attribute to.



16
17
18
# File 'lib/mscgen/message.rb', line 16

def to
  @to
end

Instance Method Details

#to_mscObject

return mscgen format text



32
33
34
35
36
# File 'lib/mscgen/message.rb', line 32

def to_msc
  message = "#{@from.name} #{allow} #{@to.name}"
  message += option_string
  message
end