Sha256: f7251f28bd564f9219d839bb98dc84470da6ece49d1e983ecb9caa17d17af913

Contents?: true

Size: 640 Bytes

Versions: 1

Compression:

Stored size: 640 Bytes

Contents

module VisualizeRuby
  class Node
    attr_reader :name
    attr_accessor :type
    def initialize(name:, type: :action)
      @name = name
      @type = type
    end

    def to_sym
      name.to_s.gsub(" ", "_").to_sym
    end

    def to_a
      [type, to_sym]
    end

    def type_display
      case type
      when :decision
        "<>"
      when :action
        "[]"
      end
    end

    def shape
      case type
      when :decision
        :diamond
      when :action
        :ellipse
      end
    end

    def inspect
      "#<VisualizeRuby::Node #{type_display} #{name}>"
    end

    alias_method :to_s, :inspect
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
visualize_ruby-0.1.0 lib/visualize_ruby/node.rb