Class: Markdoc::Sequence::Role
- Inherits:
-
Object
- Object
- Markdoc::Sequence::Role
- Includes:
- Comparable
- Defined in:
- lib/markdoc/sequence.rb
Instance Attribute Summary collapse
-
#border ⇒ Object
Returns the value of attribute border.
-
#column ⇒ Object
Returns the value of attribute column.
-
#fill ⇒ Object
Returns the value of attribute fill.
-
#font ⇒ Object
Returns the value of attribute font.
-
#height ⇒ Object
Returns the value of attribute height.
-
#id ⇒ Object
Returns the value of attribute id.
-
#label ⇒ Object
Returns the value of attribute label.
-
#line ⇒ Object
Returns the value of attribute line.
-
#messages ⇒ Object
Returns the value of attribute messages.
-
#offsetx ⇒ Object
Returns the value of attribute offsetx.
-
#offsety ⇒ Object
Returns the value of attribute offsety.
-
#prev ⇒ Object
Returns the value of attribute prev.
-
#radius ⇒ Object
Returns the value of attribute radius.
-
#spacing ⇒ Object
Returns the value of attribute spacing.
-
#succ ⇒ Object
Returns the value of attribute succ.
-
#width ⇒ Object
Returns the value of attribute width.
Instance Method Summary collapse
- #<=>(o) ⇒ Object
- #center ⇒ Object
-
#initialize(args) ⇒ Role
constructor
A new instance of Role.
- #print ⇒ Object
- #type ⇒ Object
- #x ⇒ Object
- #y ⇒ Object
Constructor Details
#initialize(args) ⇒ Role
Returns a new instance of Role.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/markdoc/sequence.rb', line 44 def initialize(args) self. = [] self.id = args[:id].strip self.label = args[:label].strip # ui settings self.column = args[:column] self.offsetx = args[:diagram][:offsetx] self.offsety = args[:diagram][:offsety] self.border = args[:ui][:border] self.fill = args[:ui][:fill] self.radius = args[:ui][:radius] self.spacing = args[:ui][:spacing] self.width = args[:ui][:width] self.height = args[:ui][:height] self.line = args[:ui][:line] self.font = args[:ui][:font] end |
Instance Attribute Details
#border ⇒ Object
Returns the value of attribute border.
40 41 42 |
# File 'lib/markdoc/sequence.rb', line 40 def border @border end |
#column ⇒ Object
Returns the value of attribute column.
40 41 42 |
# File 'lib/markdoc/sequence.rb', line 40 def column @column end |
#fill ⇒ Object
Returns the value of attribute fill.
40 41 42 |
# File 'lib/markdoc/sequence.rb', line 40 def fill @fill end |
#font ⇒ Object
Returns the value of attribute font.
40 41 42 |
# File 'lib/markdoc/sequence.rb', line 40 def font @font end |
#height ⇒ Object
Returns the value of attribute height.
40 41 42 |
# File 'lib/markdoc/sequence.rb', line 40 def height @height end |
#id ⇒ Object
Returns the value of attribute id.
40 41 42 |
# File 'lib/markdoc/sequence.rb', line 40 def id @id end |
#label ⇒ Object
Returns the value of attribute label.
40 41 42 |
# File 'lib/markdoc/sequence.rb', line 40 def label @label end |
#line ⇒ Object
Returns the value of attribute line.
40 41 42 |
# File 'lib/markdoc/sequence.rb', line 40 def line @line end |
#messages ⇒ Object
Returns the value of attribute messages.
40 41 42 |
# File 'lib/markdoc/sequence.rb', line 40 def @messages end |
#offsetx ⇒ Object
Returns the value of attribute offsetx.
40 41 42 |
# File 'lib/markdoc/sequence.rb', line 40 def offsetx @offsetx end |
#offsety ⇒ Object
Returns the value of attribute offsety.
40 41 42 |
# File 'lib/markdoc/sequence.rb', line 40 def offsety @offsety end |
#prev ⇒ Object
Returns the value of attribute prev.
40 41 42 |
# File 'lib/markdoc/sequence.rb', line 40 def prev @prev end |
#radius ⇒ Object
Returns the value of attribute radius.
40 41 42 |
# File 'lib/markdoc/sequence.rb', line 40 def radius @radius end |
#spacing ⇒ Object
Returns the value of attribute spacing.
40 41 42 |
# File 'lib/markdoc/sequence.rb', line 40 def spacing @spacing end |
#succ ⇒ Object
Returns the value of attribute succ.
40 41 42 |
# File 'lib/markdoc/sequence.rb', line 40 def succ @succ end |
#width ⇒ Object
Returns the value of attribute width.
40 41 42 |
# File 'lib/markdoc/sequence.rb', line 40 def width @width end |
Instance Method Details
#<=>(o) ⇒ Object
63 64 65 |
# File 'lib/markdoc/sequence.rb', line 63 def <=> o column <=> o.column end |
#center ⇒ Object
82 83 84 |
# File 'lib/markdoc/sequence.rb', line 82 def center x + width/2 end |
#print ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/markdoc/sequence.rb', line 94 def print elements = [] case type when :actor elements << %Q[<g transform="translate(#{x+10},0)"><path d="M74,64 a30,30 0 0,0 -27,-27 a16,18 0 1,0 -16,0 a30,30 0, 0,0 -27,27 z" stroke-width="#{line}" fill="#{fill}" stroke="#{border}"/></g>] elements << %Q[<text x="#{x+46-2*id.size}" y="#{y+height-5}" font-family="#{font}" font-size="12" fill="#{border}">#{id}</text>] else elements << %Q[<rect fill="#{fill}" stroke="#{border}" rx="#{radius}" ry="#{radius}" x="#{x}" y="#{y}" width="#{width}" height="#{height}" stroke-width="#{line}"/>] elements << %Q[<text x="#{x+10}" y="#{y+20}" font-family="#{font}" font-size="12" fill="#{border}">#{label}</text>] end x1 = center y1 = offsety + height x2 = center y2 = .last.y + 10 elements << %Q[<line x1="#{x1}" y1="#{y1}" x2="#{x2}" y2="#{y2}" stroke="#{border}" stroke-width="#{line}"/>] elements.join("\n") end |
#type ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/markdoc/sequence.rb', line 67 def type case label when /actor/i :actor when /database/i :database when /site|web/i :website when /application|system/i :system else :component end end |
#x ⇒ Object
86 87 88 |
# File 'lib/markdoc/sequence.rb', line 86 def x offsetx + column*(width + spacing) end |
#y ⇒ Object
90 91 92 |
# File 'lib/markdoc/sequence.rb', line 90 def y offsety end |