module Pipetree::Railway::Inspect

Constants

Operator

Public Instance Methods

inspect_func(step) click to toggle source
# File lib/pipetree/railway/inspect.rb, line 6
def inspect_func(step)
  @inspect[step]
end
inspect_line(names) click to toggle source
# File lib/pipetree/railway/inspect.rb, line 12
def inspect_line(names)
  string = names.collect { |i, (track, name)| "#{Operator[track]}#{name}" }.join(",")
  "[#{string}]"
end
inspect_rows(names) click to toggle source
# File lib/pipetree/railway/inspect.rb, line 17
def inspect_rows(names)
  string = names.collect do |i, (track, name)|
    operator = Operator[track]

    op = "#{operator}#{name}"
    padding = 38

    proc = if operator == "<"
      sprintf("%- #{padding}s", op)
    elsif [">", ">>", "&"].include?(operator.to_s)
      sprintf("% #{padding}s", op)
    else
      pad = " " * ((padding - op.length) / 2)
      "#{pad}#{op}#{pad}"
    end

    proc = proc.gsub(" ", "=")

    sprintf("%2d %s", i, proc)
  end.join("\n")
  "\n#{string}"
end