class Markdoc::Sequence::Message

Attributes

color[RW]
comment[RW]
dash[RW]
dest[RW]
font[RW]
label[RW]
line[RW]
offset[RW]
op[RW]
options[RW]
row[RW]
size[RW]
source[RW]
spacing[RW]

Public Class Methods

new(args) click to toggle source
# File lib/markdoc/sequence.rb, line 120
def initialize(args)
  self.options = []
  self.label = args[:label].strip
  self.comment = args[:comment].strip

  self.op = args[:op]
  self.row = args[:row]
  # ui
  self.offset  = args[:ui][:offset]
  self.color   = args[:ui][:color]
  self.font    = args[:ui][:font]
  self.size    = args[:ui][:size]
  self.spacing = args[:ui][:spacing]
  self.line    = args[:ui][:line]
  self.dash    = args[:ui][:dash]

  if op.index('~')
    options << %Q[stroke-dasharray="#{dash}"]
  elsif op.index('-').nil?
    raise "Message direction must be one of ->, ~>, <-, <~"
  end

  if op.index('>')
    self.source, self.dest = args[:role1], args[:role2]
  elsif op.index('<')
    self.source, self.dest = args[:role2], args[:role1]
  else
    raise "Message direction must be one of ->, ~>, <-, <~"
  end

  source.messages << self
  dest.messages << self unless source.eql?(dest)
end

Public Instance Methods

print() click to toggle source
y() click to toggle source
# File lib/markdoc/sequence.rb, line 196
def y
  offset + row*spacing
end

Private Instance Methods

split(text, max = 35) click to toggle source
# File lib/markdoc/sequence.rb, line 202
def split(text, max = 35)
  ary = []
  line = ''
  text.split.each do |word|
    if (line + word).length < max
      line << ' ' << word
    else
      ary << line
      line = word
    end
  end
  ary << line if line.length > 0
  ary
end