Class: Prolefeed

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeProlefeed

Returns a new instance of Prolefeed.



3
4
5
6
# File 'lib/prolefeed.rb', line 3

def initialize
  @book_ends = []
  @story = []
end

Instance Attribute Details

#book_endsObject (readonly)

Returns the value of attribute book_ends.



2
3
4
# File 'lib/prolefeed.rb', line 2

def book_ends
  @book_ends
end

#storyObject (readonly)

Returns the value of attribute story.



2
3
4
# File 'lib/prolefeed.rb', line 2

def story
  @story
end

Instance Method Details

#add_to_bookends(string) ⇒ Object



8
9
10
# File 'lib/prolefeed.rb', line 8

def add_to_bookends(string)
  self.book_ends << string
end

#add_to_story(string) ⇒ Object



12
13
14
# File 'lib/prolefeed.rb', line 12

def add_to_story(string)
  self.story << string
end

#generateObject



16
17
18
19
20
21
22
23
# File 'lib/prolefeed.rb', line 16

def generate
  generated_story = []
  shuffled_bookends = book_ends.shuffle
  shuffled_story = story.shuffle
  introduction = shuffled_bookends.pop unless shuffled_bookends.empty?
  conclusion = shuffled_bookends.pop unless shuffled_bookends.empty?
  shuffled_story.unshift(introduction).push(conclusion)
end