Class: Empyrean::TemplateRenderer
- Inherits:
-
Object
- Object
- Empyrean::TemplateRenderer
- Defined in:
- lib/empyrean/templaterenderer.rb
Instance Method Summary collapse
-
#initialize(config, template, parsed_tweets) ⇒ TemplateRenderer
constructor
Initializes a new TemplateRenderer.
-
#render ⇒ Object
Renders @template.
Constructor Details
#initialize(config, template, parsed_tweets) ⇒ TemplateRenderer
Initializes a new TemplateRenderer.
template: The template to use (i.e. not the file name) parsed_tweets: The dict that gets returned by TweetParser::merge_parsed
30 31 32 33 34 |
# File 'lib/empyrean/templaterenderer.rb', line 30 def initialize(config, template, parsed_tweets) @config = config @template = template @parsed = parsed_tweets end |
Instance Method Details
#render ⇒ Object
Renders @template.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/empyrean/templaterenderer.rb', line 38 def render mentions = mentions_erb = smileys = smileys_erb clients = clients_erb counters = { tweets: @parsed[:tweet_count], retweets: @parsed[:retweet_count], retweets_percentage: (@parsed[:retweet_count] * 100 / @parsed[:tweet_count].to_f).round(2), selftweets: @parsed[:selftweet_count], selftweets_percentage: (@parsed[:selftweet_count] * 100 / @parsed[:tweet_count].to_f).round(2) } times_of_day = times_erb erb = ERB.new @template erb.result binding end |