class Erlash::ArrayRecursiveFormatter
Experimental
Public Instance Methods
format()
click to toggle source
# File lib/erlash/formatters/array_recursive_formatter.rb, line 6 def format recursive_format end
Private Instance Methods
recursive_format()
click to toggle source
# File lib/erlash/formatters/array_recursive_formatter.rb, line 12 def recursive_format objs = recursive_nesting(object) objs.each_with_object([]) do |n, s| if n.val.is_a?(Hash) format_elem(n.val).each do |fh| s << "#{" "*n.offset}#{fh}" end else s << " #{" "*n.offset} - #{format_elem(n.val)}" end end.flatten.join("\n") end
recursive_nesting(e, acc = [], offset = 0)
click to toggle source
# File lib/erlash/formatters/array_recursive_formatter.rb, line 25 def recursive_nesting(e, acc = [], offset = 0) if e.is_a?(Array) e.each{ |i| recursive_nesting(i, acc, offset + 1)} else acc << Nested.new(e, offset) end acc end