Class: CoopAl::Adventure
- Inherits:
-
Object
- Object
- CoopAl::Adventure
- Defined in:
- lib/coop_al/adventure.rb
Overview
Adventure
Instance Attribute Summary collapse
-
#chapters ⇒ Object
readonly
Returns the value of attribute chapters.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #add_chapter(chapter) ⇒ Object
- #add_entry(path) ⇒ Object
- #all_chapter_names ⇒ Object
- #all_entries ⇒ Object
- #chapter(name) ⇒ Object
- #chapter?(name) ⇒ Boolean
- #chapter_by_path(path) ⇒ Object
- #chapter_paths ⇒ Object
- #full_name ⇒ Object
-
#initialize(name, description) ⇒ Adventure
constructor
A new instance of Adventure.
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
#chapters ⇒ Object (readonly)
Returns the value of attribute chapters.
6 7 8 |
# File 'lib/coop_al/adventure.rb', line 6 def chapters @chapters end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
6 7 8 |
# File 'lib/coop_al/adventure.rb', line 6 def description @description end |
#name ⇒ Object (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_names ⇒ Object
23 24 25 |
# File 'lib/coop_al/adventure.rb', line 23 def all_chapter_names @chapters.keys end |
#all_entries ⇒ Object
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
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_paths ⇒ Object
31 32 33 |
# File 'lib/coop_al/adventure.rb', line 31 def chapter_paths @chapters.values.map(&:absolute_path) end |
#full_name ⇒ Object
48 49 50 |
# File 'lib/coop_al/adventure.rb', line 48 def full_name @description end |