module Dialogue

Dialogue is the module for traversing an existing tree.

Public Class Methods

display_branch(branch, branch_no, debug = false) click to toggle source

Format and display a branch and the options

@param branch [Hash] A branch data set @param branch_no [Integer] The branch number @param debug [Boolean] Status of showing debug information

# File lib/sapling/dialogue.rb, line 22
def self.display_branch(branch, branch_no, debug = false)
  puts "\n[ Branch: #{branch_no} ]" if debug
  puts "\n#{branch['desc']}\n\n"

  branch['options'].each_pair do |k, v|
    puts "\t#{k}: #{v.keys[0]}"
    puts "\t\t[ Goes to branch #{v.values[0]} ]\n" if debug
  end
end
display_trunk(trunk, debug = false) click to toggle source

Format and display the trunk

@param trunk [Hash] The trunk hash @param debug [Boolean] The status of showing debug information

# File lib/sapling/dialogue.rb, line 9
def self.display_trunk(trunk, debug = false)
  40.times { print '-' }
  puts "\n[ Trunk ]\n" if debug
  puts "\n#{trunk['trunk']}"
  40.times { print '-' }
  puts "\n"
end