Class: PDF::Storycards::Story
- Inherits:
-
Object
- Object
- PDF::Storycards::Story
- Defined in:
- lib/pdf/storycards/story.rb
Overview
The string Story#narrative is imbued with a method called to_sentence, which formats the story narrative as a single sentence without newlines.
Instance Attribute Summary collapse
-
#meta_data ⇒ Object
Returns the value of attribute meta_data.
-
#narrative ⇒ Object
readonly
Returns the value of attribute narrative.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Class Method Summary collapse
Instance Method Summary collapse
- #add_scenario(scenario) ⇒ Object
- #current_scenario ⇒ Object
-
#initialize(title, narrative) ⇒ Story
constructor
A new instance of Story.
Constructor Details
#initialize(title, narrative) ⇒ Story
Returns a new instance of Story.
6 7 8 9 10 11 12 13 14 |
# File 'lib/pdf/storycards/story.rb', line 6 def initialize(title, narrative) @meta_data = {} @title = title @narrative = narrative def @narrative.to_sentence self.sub(/^\s*I want/, ", I want").gsub(/^\s*So that/, ", so that").split($/).join(" ").gsub(' ,',',').squeeze(" ") end @scenarios = [] end |
Instance Attribute Details
#meta_data ⇒ Object
Returns the value of attribute meta_data.
17 18 19 |
# File 'lib/pdf/storycards/story.rb', line 17 def @meta_data end |
#narrative ⇒ Object (readonly)
Returns the value of attribute narrative.
16 17 18 |
# File 'lib/pdf/storycards/story.rb', line 16 def narrative @narrative end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
16 17 18 |
# File 'lib/pdf/storycards/story.rb', line 16 def title @title end |
Class Method Details
.to_sentence ⇒ Object
10 11 12 |
# File 'lib/pdf/storycards/story.rb', line 10 def @narrative.to_sentence self.sub(/^\s*I want/, ", I want").gsub(/^\s*So that/, ", so that").split($/).join(" ").gsub(' ,',',').squeeze(" ") end |
Instance Method Details
#add_scenario(scenario) ⇒ Object
19 20 21 |
# File 'lib/pdf/storycards/story.rb', line 19 def add_scenario(scenario) @scenarios << scenario end |
#current_scenario ⇒ Object
23 24 25 |
# File 'lib/pdf/storycards/story.rb', line 23 def current_scenario @scenarios.last end |