Class: Architect::Class

Inherits:
Node
  • Object
show all
Defined in:
lib/architect/class.rb

Instance Attribute Summary collapse

Attributes inherited from Node

#name

Instance Method Summary collapse

Methods inherited from Node

#==

Constructor Details

#initialize(markup) ⇒ Class

Returns a new instance of Class.



9
10
11
12
13
14
15
16
17
18
# File 'lib/architect/class.rb', line 9

def initialize(markup)
  if markup.index("|").nil?
    @name = markup
  else
    tokens = /^(?<name>.+?)\|/.match(markup)
    @name = tokens[:name]
  end
  @markup = format(markup)
  @style = {shape: "record"}
end

Instance Attribute Details

#graphnodeObject

Returns the value of attribute graphnode.



7
8
9
# File 'lib/architect/class.rb', line 7

def graphnode
  @graphnode
end

#markupObject

Returns the value of attribute markup.



7
8
9
# File 'lib/architect/class.rb', line 7

def markup
  @markup
end

Instance Method Details

#format(markup) ⇒ Object



20
21
22
# File 'lib/architect/class.rb', line 20

def format(markup)
  return "{" + markup.gsub(";", "\\n") + "}"
end

#graph(g) ⇒ Object



24
25
26
# File 'lib/architect/class.rb', line 24

def graph(g)
  @graphnode = g.add_nodes(@markup, @style)
end