Class: VisualizeRuby::Node
- Inherits:
-
Object
- Object
- VisualizeRuby::Node
- Defined in:
- lib/visualize_ruby/node.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#style ⇒ Object
readonly
Returns the value of attribute style.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(name:, type: :action, style: :rounded) ⇒ Node
constructor
A new instance of Node.
- #inspect ⇒ Object (also: #to_s)
- #shape ⇒ Object
- #to_a ⇒ Object
- #to_sym ⇒ Object
- #type_display ⇒ Object
Constructor Details
#initialize(name:, type: :action, style: :rounded) ⇒ Node
Returns a new instance of Node.
6 7 8 9 10 |
# File 'lib/visualize_ruby/node.rb', line 6 def initialize(name:, type: :action, style: :rounded) @name = name.to_s @type = type @style = style end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/visualize_ruby/node.rb', line 3 def name @name end |
#style ⇒ Object (readonly)
Returns the value of attribute style.
3 4 5 |
# File 'lib/visualize_ruby/node.rb', line 3 def style @style end |
#type ⇒ Object
Returns the value of attribute type.
4 5 6 |
# File 'lib/visualize_ruby/node.rb', line 4 def type @type end |
Instance Method Details
#inspect ⇒ Object Also known as: to_s
38 39 40 |
# File 'lib/visualize_ruby/node.rb', line 38 def inspect "#<VisualizeRuby::Node #{type_display} #{name}>" end |
#shape ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/visualize_ruby/node.rb', line 29 def shape case type when :decision :diamond when :action :ellipse end end |
#to_a ⇒ Object
16 17 18 |
# File 'lib/visualize_ruby/node.rb', line 16 def to_a [type, name.to_s] end |
#to_sym ⇒ Object
12 13 14 |
# File 'lib/visualize_ruby/node.rb', line 12 def to_sym name.to_s.gsub(" ", "_").to_sym end |
#type_display ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/visualize_ruby/node.rb', line 20 def type_display case type when :decision "<>" when :action "[]" end end |