Module: Pipetree::Inspect

Included in:
Railway, Railway::Inspect
Defined in:
lib/pipetree/inspect.rb

Instance Method Summary collapse

Instance Method Details

#inspect(options = { style: :line }) ⇒ Object

TODO: implement for nested TODO: remove in Representable::Debug.



4
5
6
7
8
9
10
11
# File 'lib/pipetree/inspect.rb', line 4

def inspect(options={ style: :line })
  names = each_with_index.collect do |func, i|
    [i, inspect_func(func)]
  end

  return inspect_line(names) if options[:style] == :line
  inspect_rows(names)
end

#inspect_func(func) ⇒ Object



13
14
15
# File 'lib/pipetree/inspect.rb', line 13

def inspect_func(func)
  func
end

#inspect_line(names) ⇒ Object



17
18
19
20
# File 'lib/pipetree/inspect.rb', line 17

def inspect_line(names)
  string = names.collect { |i, name| "#{name}" }.join("|>")
  "[#{string}]"
end

#inspect_row(index, name) ⇒ Object



32
33
34
# File 'lib/pipetree/inspect.rb', line 32

def inspect_row(index, name)
  "#{index}|>#{name}"
end

#inspect_rows(names) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/pipetree/inspect.rb', line 22

def inspect_rows(names)
  string = names.collect do |i, name|
    index = sprintf("%2d", i)
    inspect_row(index, name)
  end.join("\n")
    # name  = sprintf("%-60.300s", name) # no idea what i'm doing here.
    # "#{index}) #{name} #{func.source_location.join(":")}"
  "\n#{string}"
end