Class: ZombieWriter::Randomization
- Inherits:
-
Object
- Object
- ZombieWriter::Randomization
- Defined in:
- lib/zombie_writer.rb
Instance Attribute Summary collapse
-
#labels ⇒ Object
readonly
Returns the value of attribute labels.
-
#paragraph_data ⇒ Object
readonly
Returns the value of attribute paragraph_data.
-
#renderer ⇒ Object
readonly
Returns the value of attribute renderer.
Instance Method Summary collapse
- #add_string(paragraph) ⇒ Object
- #generate_articles ⇒ Object
-
#initialize ⇒ Randomization
constructor
A new instance of Randomization.
Constructor Details
#initialize ⇒ Randomization
Returns a new instance of Randomization.
106 107 108 109 110 |
# File 'lib/zombie_writer.rb', line 106 def initialize @labels = [] @paragraph_data = Hash.new @renderer = Redcarpet::Markdown.new(CustomStripDownRender) end |
Instance Attribute Details
#labels ⇒ Object (readonly)
Returns the value of attribute labels.
104 105 106 |
# File 'lib/zombie_writer.rb', line 104 def labels @labels end |
#paragraph_data ⇒ Object (readonly)
Returns the value of attribute paragraph_data.
104 105 106 |
# File 'lib/zombie_writer.rb', line 104 def paragraph_data @paragraph_data end |
#renderer ⇒ Object (readonly)
Returns the value of attribute renderer.
104 105 106 |
# File 'lib/zombie_writer.rb', line 104 def renderer @renderer end |
Instance Method Details
#add_string(paragraph) ⇒ Object
112 113 114 115 116 117 118 |
# File 'lib/zombie_writer.rb', line 112 def add_string(paragraph) content = paragraph[:content] paragraph_data[content] = ZombieWriter.citation_constructor(paragraph) labels << content end |
#generate_articles ⇒ Object
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/zombie_writer.rb', line 120 def generate_articles number_of_paragraphs = labels.length possible_paragraphs = labels.shuffle possible_paragraphs.each_slice(5).with_index.map do |cluster, index| article_for_summarization = generate_article(cluster) do |content| renderer.render(content) end final_article = generate_article(cluster) do |content| citation = paragraph_data[content] "#{content}#{citation}" end header = ZombieWriter.header(index, article_for_summarization) ZombieWriter.formatted_article(header, final_article) end end |