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.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(name:, type: :action) ⇒ 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) ⇒ Node
Returns a new instance of Node.
5 6 7 8 |
# File 'lib/visualize_ruby/node.rb', line 5 def initialize(name:, type: :action) @name = name.to_s @type = type 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 |
#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
36 37 38 |
# File 'lib/visualize_ruby/node.rb', line 36 def inspect "#<VisualizeRuby::Node #{type_display} #{name}>" end |
#shape ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/visualize_ruby/node.rb', line 27 def shape case type when :decision :diamond when :action :ellipse end end |
#to_a ⇒ Object
14 15 16 |
# File 'lib/visualize_ruby/node.rb', line 14 def to_a [type, to_sym] end |
#to_sym ⇒ Object
10 11 12 |
# File 'lib/visualize_ruby/node.rb', line 10 def to_sym name.to_s.gsub(" ", "_").to_sym end |
#type_display ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/visualize_ruby/node.rb', line 18 def type_display case type when :decision "<>" when :action "[]" end end |