Sha256: eb9900c3216bd6b1894160b53ea6d3df38eb88cc538962d3066f2425e39b3a65

Contents?: true

Size: 538 Bytes

Versions: 5

Compression:

Stored size: 538 Bytes

Contents

module Taketo
  module Printer
    def initialize
      @indent_level = 0
      @print_result = ""
    end

    def result
      @print_result.chomp
    end

    private

    def indent(level = nil)
      @first_indent ||= level || @indent_level
      level ? @indent_level = level - @first_indent : @indent_level += 1
      yield
    end

    def put(str = nil)
      @print_result += ("  " * @indent_level + str.to_s).rstrip.chomp + "\n"
    end

    def put_optional(str, value)
      put "#{str} #{value}" if value
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
taketo-0.2.0.alpha lib/taketo/printer.rb
taketo-0.1.3 lib/taketo/printer.rb
taketo-0.1.2 lib/taketo/printer.rb
taketo-0.1.1 lib/taketo/printer.rb
taketo-0.1.0 lib/taketo/printer.rb