From a1e8c6fc94297741b1ee00e821b3bf9d4d51e189 Mon Sep 17 00:00:00 2001 From: Lars Henrik Mai Date: Sat, 25 Oct 2014 17:33:47 +0200 Subject: use data for tweets and wiki changes --- helpers/twitter_helpers.rb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 helpers/twitter_helpers.rb (limited to 'helpers/twitter_helpers.rb') diff --git a/helpers/twitter_helpers.rb b/helpers/twitter_helpers.rb new file mode 100644 index 0000000..1a3850c --- /dev/null +++ b/helpers/twitter_helpers.rb @@ -0,0 +1,27 @@ +require 'date' + +module TwitterHelpers + + class Tweet + + attr_reader :tweet_id, :text, :user_name + + def initialize(atts={}) + @tweet_id = atts.fetch("id") + @created_at = DateTime.parse(atts.fetch("created_at")) + @text = atts.fetch("text") + @user_name = atts.fetch("user").fetch("name") + @user_screen_name = atts.fetch("user").fetch("screen_name") + end + + def created_at + @created_at.strftime(CalendarHelpers::FORMATS[:date_string_short]) + end + + def user_screen_name + "@#{@user_screen_name}" + end + + end + +end -- cgit v1.2.1