module Kernel
Public Instance Methods
aa_ancestors()
click to toggle source
Ascii Art Ancestors
Examples¶ ↑
define class
class BaseHogeForAncestors;end class HogeForAncestors < BaseHogeForAncestors;end
execute aa_ancestors
puts HogeForAncestors.aa_ancestors
result is …
---------------------- | BasicObject | ---------------------- | ---------------------- | Kernel | ---------------------- | ---------------------- | Object | ---------------------- | ---------------------- |BaseHogeForAncestors| ---------------------- | ---------------------- | HogeForAncestors | ----------------------
# File lib/pry-aa_ancestors.rb, line 112 def aa_ancestors max_class = max_size_class max = max_class.to_s.size ca = centered_ancestors(max) ba = surrounded_ancestors(ca) connected_box_ancestors(ba, max) end
Private Instance Methods
ancestors_connector(max)
click to toggle source
# File lib/pry-aa_ancestors.rb, line 138 def ancestors_connector(max) connector = '|'.rjust((max + 2) / 2) "\n#{connector}\n" end
centered_ancestors(max)
click to toggle source
# File lib/pry-aa_ancestors.rb, line 126 def centered_ancestors(max) ancestors.reverse.map { |v|v.to_s.center max } end
connected_box_ancestors(ba, max)
click to toggle source
# File lib/pry-aa_ancestors.rb, line 134 def connected_box_ancestors(ba, max) ba.join(ancestors_connector(max)) end
max_size_class()
click to toggle source
# File lib/pry-aa_ancestors.rb, line 122 def max_size_class ancestors.max_by { |v|v.to_s.size } end
surrounded_ancestors(ca)
click to toggle source
# File lib/pry-aa_ancestors.rb, line 130 def surrounded_ancestors(ca) ca.reduce([]) { |a, e|a << e.surround } end