summaryrefslogtreecommitdiff
path: root/helpers/twitter_helpers.rb
blob: 1a3850c8962a3f82926bd3943d0791437b7966f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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