Module: Dialogue

Defined in:
lib/sapling/dialogue.rb

Overview

Dialogue is the module for traversing an existing tree.

Defined Under Namespace

Classes: Speaker

Class Method Summary collapse

Class Method Details

.display_branch(branch, branch_no, debug = false) ⇒ Object

Format and display a branch and the options

Parameters:

  • branch (Hash)

    A branch data set

  • branch_no (Integer)

    The branch number

  • debug (Boolean) (defaults to: false)

    Status of showing debug information



23
24
25
26
27
28
29
30
31
# File 'lib/sapling/dialogue.rb', line 23

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) ⇒ Object

Format and display the trunk

Parameters:

  • trunk (Hash)

    The trunk hash

  • debug (Boolean) (defaults to: false)

    The status of showing debug information



10
11
12
13
14
15
16
# File 'lib/sapling/dialogue.rb', line 10

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