Class: CoopAl::Adventure

Inherits:
Object
  • Object
show all
Defined in:
lib/coop_al/adventure.rb

Overview

Adventure

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, description) ⇒ Adventure

Returns a new instance of Adventure.



8
9
10
11
12
13
# File 'lib/coop_al/adventure.rb', line 8

def initialize(name, description)
  @name = name
  @description = description
  @entries = []
  @chapters = {}
end

Instance Attribute Details

#chaptersObject (readonly)

Returns the value of attribute chapters.



6
7
8
# File 'lib/coop_al/adventure.rb', line 6

def chapters
  @chapters
end

#descriptionObject (readonly)

Returns the value of attribute description.



6
7
8
# File 'lib/coop_al/adventure.rb', line 6

def description
  @description
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/coop_al/adventure.rb', line 6

def name
  @name
end

Instance Method Details

#add_chapter(chapter) ⇒ Object



19
20
21
# File 'lib/coop_al/adventure.rb', line 19

def add_chapter(chapter)
  @chapters[chapter.name] = chapter
end

#add_entry(path) ⇒ Object



15
16
17
# File 'lib/coop_al/adventure.rb', line 15

def add_entry(path)
  @entries << path
end

#all_chapter_namesObject



23
24
25
# File 'lib/coop_al/adventure.rb', line 23

def all_chapter_names
  @chapters.keys
end

#all_entriesObject



35
36
37
# File 'lib/coop_al/adventure.rb', line 35

def all_entries
  @entries.map { |e| Path.absolute(@name, e) }
end

#chapter(name) ⇒ Object



43
44
45
46
# File 'lib/coop_al/adventure.rb', line 43

def chapter(name)
  raise "Chapter (#{name}) not found" unless @chapters.key?(name)
  @chapters[name]
end

#chapter?(name) ⇒ Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/coop_al/adventure.rb', line 39

def chapter?(name)
  @chapters.key?(name)
end

#chapter_by_path(path) ⇒ Object



27
28
29
# File 'lib/coop_al/adventure.rb', line 27

def chapter_by_path(path)
  @chapters[path.chapter]
end

#chapter_pathsObject



31
32
33
# File 'lib/coop_al/adventure.rb', line 31

def chapter_paths
  @chapters.values.map(&:absolute_path)
end

#full_nameObject



48
49
50
# File 'lib/coop_al/adventure.rb', line 48

def full_name
  @description
end