Class: RailsERD::Diagram::Mermaid

Inherits:
RailsERD::Diagram show all
Defined in:
lib/rails_erd/diagram/mermaid.rb

Instance Attribute Summary collapse

Attributes inherited from RailsERD::Diagram

#domain, #options

Instance Method Summary collapse

Methods inherited from RailsERD::Diagram

create, #create, #generate, #initialize, #recurse_into_relationships, #save

Constructor Details

This class inherits a constructor from RailsERD::Diagram

Instance Attribute Details

#graphObject

Returns the value of attribute graph.



9
10
11
# File 'lib/rails_erd/diagram/mermaid.rb', line 9

def graph
  @graph
end

Instance Method Details

#arrow_body(relationship) ⇒ Object



64
65
66
# File 'lib/rails_erd/diagram/mermaid.rb', line 64

def arrow_body(relationship)
  relationship.indirect? ? ".." : "--"
end

#arrow_head(relationship) ⇒ Object



68
69
70
# File 'lib/rails_erd/diagram/mermaid.rb', line 68

def arrow_head(relationship)
  relationship.to_many? ?  ">" : ""
end

#arrow_tail(relationship) ⇒ Object



72
73
74
# File 'lib/rails_erd/diagram/mermaid.rb', line 72

def arrow_tail(relationship)
  relationship.many_to? ? "<" : ""
end

#filenameObject



52
53
54
# File 'lib/rails_erd/diagram/mermaid.rb', line 52

def filename
  "#{options.filename}.mmd"
end

#relation_arrow(relationship) ⇒ Object



56
57
58
59
60
61
62
# File 'lib/rails_erd/diagram/mermaid.rb', line 56

def relation_arrow(relationship)
  arrow_body = arrow_body relationship
  arrow_head = arrow_head relationship
  arrow_tail = arrow_tail relationship

  "#{arrow_tail}#{arrow_body}#{arrow_head}"
end