class Object

Constants

SKELETON_TREE

The final tree

SKELE_BRANCH_TEXT

The default first-branch text of a new tree

SKELE_LEAF_TEXT

The default first-leaf text of the first branch of a new tree. The leaf points to it's own branch. The only way out of the program is to either force-quit or reply with option 0.

SKELE_TRUNK_TEXT

The default trunk text of a new tree

Public Instance Methods

verify_tree(file) click to toggle source

Verify that a file is a dialogue tree file.

@param file [File] The provided file @return [Boolean] True if the file is a tree; false otherwise

# File lib/sapling/utility.rb, line 41
def verify_tree(file)
  results = []
  begin
    tree = YAML.load_file(file)
    results << tree[0].keys.include?('trunk')
    results << tree[1]['branch'].keys.include?('number')
    results << tree[1]['branch'].keys.include?('text')
    results << tree[1]['branch'].keys.include?('leaf')
  rescue
    puts "Sorry chummer, I don't think this is a tree."
    puts 'Verify your YAML file is formatted properly.'
    results << false
  end

  results.include?(false) ? false : true
end