Class: VisualizeRuby::Edge
- Inherits:
-
Object
- Object
- VisualizeRuby::Edge
- Defined in:
- lib/visualize_ruby/edge.rb
Instance Attribute Summary collapse
-
#color ⇒ Object
readonly
Returns the value of attribute color.
-
#dir ⇒ Object
readonly
Returns the value of attribute dir.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#node_a ⇒ Object
readonly
Returns the value of attribute node_a.
-
#node_b ⇒ Object
readonly
Returns the value of attribute node_b.
-
#style ⇒ Object
readonly
Returns the value of attribute style.
Instance Method Summary collapse
- #direction_symbol ⇒ Object
-
#initialize(name: nil, nodes:, dir: :forward, style: :solid, color: nil) ⇒ Edge
constructor
A new instance of Edge.
- #inspect ⇒ Object (also: #to_s)
- #to_a ⇒ Object
Constructor Details
#initialize(name: nil, nodes:, dir: :forward, style: :solid, color: nil) ⇒ Edge
10 11 12 13 14 15 16 17 |
# File 'lib/visualize_ruby/edge.rb', line 10 def initialize(name: nil, nodes:, dir: :forward, style: :solid, color: nil) @name = name.to_s if name @node_a = nodes[0] @node_b = nodes[1] @dir = dir @style = style @color = color end |
Instance Attribute Details
#color ⇒ Object (readonly)
Returns the value of attribute color.
3 4 5 |
# File 'lib/visualize_ruby/edge.rb', line 3 def color @color end |
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
3 4 5 |
# File 'lib/visualize_ruby/edge.rb', line 3 def dir @dir end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/visualize_ruby/edge.rb', line 3 def name @name end |
#node_a ⇒ Object (readonly)
Returns the value of attribute node_a.
3 4 5 |
# File 'lib/visualize_ruby/edge.rb', line 3 def node_a @node_a end |
#node_b ⇒ Object (readonly)
Returns the value of attribute node_b.
3 4 5 |
# File 'lib/visualize_ruby/edge.rb', line 3 def node_b @node_b end |
#style ⇒ Object (readonly)
Returns the value of attribute style.
3 4 5 |
# File 'lib/visualize_ruby/edge.rb', line 3 def style @style end |
Instance Method Details
#direction_symbol ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/visualize_ruby/edge.rb', line 28 def direction_symbol case dir when :forward "->" when :none "-" end end |
#inspect ⇒ Object Also known as: to_s
37 38 39 |
# File 'lib/visualize_ruby/edge.rb', line 37 def inspect "#<VisualizeRuby::Edge #{to_a.join(" ")}>" end |
#to_a ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/visualize_ruby/edge.rb', line 19 def to_a [ node_a.name.to_s, name, direction_symbol, node_b.name.to_s, ].compact end |