Class: Sapling

Inherits:
Thor
  • Object
show all
Defined in:
lib/sapling.rb

Overview

The main Sapling interface.

Instance Method Summary collapse

Instance Method Details

#edit(tree = '') ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/sapling.rb', line 19

def edit(tree = '')
  puts 'Welcome to Sapling, a Dialogue Tree Utility.'
  if !tree.empty?
    puts "Loading tree: #{tree}"
    exit unless verify_tree(tree)
    gardner = Planter::Spade.new(YAML.load_file(tree, false))
  else
    puts 'Creating a new tree!'
    gardner = Planter::Spade.new(SKELETON_TREE)
  end
  gardner.plant
end

#export(tree) ⇒ Object



39
40
41
42
# File 'lib/sapling.rb', line 39

def export(tree)
  exit unless verify_tree(tree)
  puts 'Cool feature, bro!'
end

#read(tree) ⇒ Object



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

def read(tree)
  exit unless verify_tree(tree)
  puts 'Welcome to Sapling, a Dialogue Tree Utility.'
  speaker = Dialogue::Speaker.new(YAML.load_file(tree), false)
  speaker.conversation
end

#serve(tree) ⇒ Object



33
34
35
36
# File 'lib/sapling.rb', line 33

def serve(tree)
  exit unless verify_tree(tree)
  puts 'Sinatra will be cool.'
end