Class: PDF::Storycards::Story

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

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_dataObject

Returns the value of attribute meta_data.



17
18
19
# File 'lib/pdf/storycards/story.rb', line 17

def 
  @meta_data
end

#narrativeObject (readonly)

Returns the value of attribute narrative.



16
17
18
# File 'lib/pdf/storycards/story.rb', line 16

def narrative
  @narrative
end

#titleObject (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_sentenceObject



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_scenarioObject



23
24
25
# File 'lib/pdf/storycards/story.rb', line 23

def current_scenario
  @scenarios.last
end