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.



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

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.



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

def comment
  @comment
end

#destObject

Returns the value of attribute dest.



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

def dest
  @dest
end

#labelObject

Returns the value of attribute label.



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

def label
  @label
end

#sourceObject

Returns the value of attribute source.



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

def source
  @source
end

#typeObject

Returns the value of attribute type.



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

def type
  @type
end

Instance Method Details

#deliverObject



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

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

#describeObject



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

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



67
68
69
# File 'lib/markdoc/sequence.rb', line 67

def height
  source == dest ? 2 : 1
end

#rolesObject



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

def roles
  [source, dest]
end