Sha256: dad3f5b794039ed1740fa19e845d085697c560426057e9a05300d0e42196d87b

Contents?: true

Size: 845 Bytes

Versions: 2

Compression:

Stored size: 845 Bytes

Contents

module Dumper
  private
    def heading(string)
      length = string.length + 5
      
      puts "=" * length
      puts string.upcase
      puts "=" * length
      yield
      puts "=" * length
      puts
    end
    
    def section(string)
      puts string
      puts "-" * (string.length + 2)
      yield
      puts
    end
    
    def indent(string, length = 2, character = " ")
      output = ""
      
      string.each_line do |line|
        output << (character * length) + line
      end
      
      return output
    end
    
    def inspect_tree(tree)
      output = ""
      
      tree.each do |branch|
        if branch.class.to_s == "Array" # TODO better way?
          output << indent(inspect_tree(branch))
        else
          output << "#{branch.inspect}\n"
        end
      end
      
      return output
    end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
odin-0.0.4 lib/dumper.rb
odin-0.1.0.alpha.1 lib/dumper.rb