Class: Markdoc::Sequence::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/markdoc/sequence.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, source, dest, label, comment) ⇒ Message

Returns a new instance of Message.



44
45
46
# File 'lib/markdoc/sequence.rb', line 44

def initialize(type, source, dest, label, comment)
  self.type, self.source, self.dest, self.label, self.comment = type, source, dest, label.strip, comment.strip
end

Instance Attribute Details

#commentObject

Returns the value of attribute comment.



43
44
45
# File 'lib/markdoc/sequence.rb', line 43

def comment
  @comment
end

#destObject

Returns the value of attribute dest.



43
44
45
# File 'lib/markdoc/sequence.rb', line 43

def dest
  @dest
end

#labelObject

Returns the value of attribute label.



43
44
45
# File 'lib/markdoc/sequence.rb', line 43

def label
  @label
end

#sourceObject

Returns the value of attribute source.



43
44
45
# File 'lib/markdoc/sequence.rb', line 43

def source
  @source
end

#typeObject

Returns the value of attribute type.



43
44
45
# File 'lib/markdoc/sequence.rb', line 43

def type
  @type
end

Instance Method Details

#deliverObject



52
53
54
# File 'lib/markdoc/sequence.rb', line 52

def deliver
  %Q[#{type}(#{source.id},#{dest.id}, "#{label}");]
end

#describeObject



56
57
58
59
60
61
# File 'lib/markdoc/sequence.rb', line 56

def describe
  return if comment.empty?
  width = comment.length > 10 ? 1 : comment.length * 0.13
  width = 0.5 if width < 0.5
  %Q[comment(#{dest.id},C,up 0.2 right, wid #{'%.1f' % width} ht 0.3 "#{comment}");]
end

#heightObject



63
64
65
# File 'lib/markdoc/sequence.rb', line 63

def height
  source == dest ? 2 : 1
end

#rolesObject



48
49
50
# File 'lib/markdoc/sequence.rb', line 48

def roles
  [source, dest]
end