Class: Prolefeed
- Inherits:
-
Object
- Object
- Prolefeed
- Defined in:
- lib/prolefeed.rb
Instance Attribute Summary collapse
-
#book_ends ⇒ Object
readonly
Returns the value of attribute book_ends.
-
#story ⇒ Object
readonly
Returns the value of attribute story.
Instance Method Summary collapse
- #add_to_bookends(string) ⇒ Object
- #add_to_story(string) ⇒ Object
- #generate ⇒ Object
-
#initialize ⇒ Prolefeed
constructor
A new instance of Prolefeed.
Constructor Details
#initialize ⇒ Prolefeed
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_ends ⇒ Object (readonly)
Returns the value of attribute book_ends.
2 3 4 |
# File 'lib/prolefeed.rb', line 2 def book_ends @book_ends end |
#story ⇒ Object (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 |
#generate ⇒ Object
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 |