Class: Gamefic::Props::Default

Inherits:
Object
  • Object
show all
Defined in:
lib/gamefic/props/default.rb

Overview

A collection of data related to a scene. Scenes define which Props class they use. Props can be accessed in a scene’s on_start and on_finish callbacks.

Props::Default includes the most common attributes that a scene requires. Scenes are able but not required to subclass it. Some scenes, like MultipleChoice, use specialized Props subclasses, but in many cases, Props::Default is sufficient.

Direct Known Subclasses

MultipleChoice, Pause

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scene, **context) ⇒ Default

Returns a new instance of Default.

Parameters:

  • scene (Scene)
  • context (Hash)


33
34
35
36
# File 'lib/gamefic/props/default.rb', line 33

def initialize scene, **context
  @scene = { name: scene.name, type: scene.type }
  @context = context
end

Instance Attribute Details

#contextHash (readonly) Also known as: data

A freeform dictionary of objects related to the scene. Plots can pass opts to be included in the context when they cue scenes.

Returns:

  • (Hash)


25
26
27
# File 'lib/gamefic/props/default.rb', line 25

def context
  @context
end

#inputString

Returns:



19
20
21
# File 'lib/gamefic/props/default.rb', line 19

def input
  @input
end

#promptObject



38
39
40
# File 'lib/gamefic/props/default.rb', line 38

def prompt
  @prompt ||= '>'
end

#sceneHash (readonly)

Returns:

  • (Hash)


29
30
31
# File 'lib/gamefic/props/default.rb', line 29

def scene
  @scene
end

Instance Method Details

#outputObject



42
43
44
# File 'lib/gamefic/props/default.rb', line 42

def output
  @output ||= Props::Output.new
end