diff options
Diffstat (limited to 'helpers/twitter_helpers.rb')
-rw-r--r-- | helpers/twitter_helpers.rb | 27 |
1 files changed, 27 insertions, 0 deletions
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 |