Class: CoopAl::Chapter

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

Overview

Chapter

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, description, adventure) ⇒ Chapter

Returns a new instance of Chapter.



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

def initialize(name, description, adventure)
  @name = name
  @description = description
  @adventure = adventure
  @encounters = []
  @links = []
  @links_to_downtime = false
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



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

def description
  @description
end

#encountersObject (readonly)

Returns the value of attribute encounters.



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

def encounters
  @encounters
end

Returns the value of attribute links.



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

def links
  @links
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

Instance Method Details

#absolute_pathObject



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

def absolute_path
  Path.Absolute(@adventure.name, @name)
end

#add_encounter(encounter) ⇒ Object



21
22
23
# File 'lib/coop_al/chapter.rb', line 21

def add_encounter(encounter)
  @encounters << encounter
end


25
26
27
# File 'lib/coop_al/chapter.rb', line 25

def add_link(path)
  @links << path
end

#adventure_nameObject



17
18
19
# File 'lib/coop_al/chapter.rb', line 17

def adventure_name
  @adventure.description
end

#follow(state, log) ⇒ Object



37
38
39
40
41
# File 'lib/coop_al/chapter.rb', line 37

def follow(state, log)
  @encounters.each do |encounter|
    encounter.run(state, log)
  end
end

#full_nameObject



47
48
49
# File 'lib/coop_al/chapter.rb', line 47

def full_name
  @adventure.full_name + ' - ' + @description
end


29
30
31
# File 'lib/coop_al/chapter.rb', line 29

def link_to_downtime
  @links_to_downtime = true
end

Returns:

  • (Boolean)


33
34
35
# File 'lib/coop_al/chapter.rb', line 33

def links_to_downtime?
  @links_to_downtime
end