Sha256: 9c4761d149255e130119072afdbacac7be06fe94b25b6c52db85d413c54bc8ed

Contents?: true

Size: 629 Bytes

Versions: 1

Compression:

Stored size: 629 Bytes

Contents

module VisualizeRuby
  class Edge
    attr_reader :name,
                :node_a,
                :node_b,
                :dir
    def initialize(name: nil, nodes:, dir: :forward)
      @name   = name
      @node_a = nodes[0]
      @node_b = nodes[1]
      @dir    = dir
    end

    def to_a
      [
          node_a.to_sym,
          name,
          direction_symbol,
          node_b.to_sym,
      ].compact
    end

    def direction_symbol
      case dir
      when :forward
        "->"
      end
    end

    def inspect
      "#<VisualizeRuby::Edge #{to_a.join(" ")}>"
    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/edge.rb