Class: Hanuman::Graphvizzer::Item
- Inherits:
-
Object
- Object
- Hanuman::Graphvizzer::Item
- Includes:
- Gorillib::Builder
- Defined in:
- lib/hanuman/graphvizzer/gv_models.rb
Instance Method Summary collapse
- #attrib(attr, val) ⇒ Object
- #brace(str) ⇒ Object
- #close_brace ⇒ Object
- #depth ⇒ Object
- #indent(adj = 0) ⇒ Object
- #line(str, attrs = {}, term = ';') ⇒ Object
- #quote(str) ⇒ Object
Instance Method Details
#attrib(attr, val) ⇒ Object
22 |
# File 'lib/hanuman/graphvizzer/gv_models.rb', line 22 def attrib(attr, val) "#{attr}=#{val}" ; end |
#brace(str) ⇒ Object
23 |
# File 'lib/hanuman/graphvizzer/gv_models.rb', line 23 def brace(str) "#{indent}#{str} {" ; end |
#close_brace ⇒ Object
24 |
# File 'lib/hanuman/graphvizzer/gv_models.rb', line 24 def close_brace() "#{indent}}" ; end |
#depth ⇒ Object
17 18 19 |
# File 'lib/hanuman/graphvizzer/gv_models.rb', line 17 def depth owner.depth + 1 end |
#indent(adj = 0) ⇒ Object
13 14 15 |
# File 'lib/hanuman/graphvizzer/gv_models.rb', line 13 def indent(adj=0) " " * (depth + adj) end |
#line(str, attrs = {}, term = ';') ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/hanuman/graphvizzer/gv_models.rb', line 26 def line(str, attrs={}, term=';') if attrs.empty? attr_strs = '' else width = COL_1_WIDTH - indent.length str = "%-#{width}s" % str attr_strs = attrs.map{|attr, val| attrib(attr, val) } attr_strs = "\t[ #{attr_strs.join(", ")} ]" end [indent, str, attr_strs, term].join end |
#quote(str) ⇒ Object
21 |
# File 'lib/hanuman/graphvizzer/gv_models.rb', line 21 def quote(str) str.to_s.include?('"') ? str : %Q{"#{str}"} ; end |