Method: Tuiter::User#initialize

Defined in:
lib/tuiter/data/user.rb

#initialize(data = nil) ⇒ User

Returns a new instance of User.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/tuiter/data/user.rb', line 30

def initialize(data = nil)
  unless data.nil?
    @id = data["id"]
    @name = data["name"]
    @screen_name = data["screen_name"]
    @location = data["location"]
    @description = data["description"]
    @profile_image_url = data["profile_image_url"]
    @url = data["url"]
    @protected = data["protected"]
    @followers_count = data["followers_count"]
    @profile_background_color = data["profile_background_color"]
    @profile_text_color = data["profile_text_color"]
    @profile_link_color = data["profile_link_color"]
    @profile_sidebar_fill_color = data["profile_sidebar_fill_color"]
    @profile_sidebar_border_color = data["profile_sidebar_border_color"]
    @friends_count = data["friends_count"].to_i
    @created_at = (data["created_at"] ? DateTime.parse(data["created_at"]) : DateTime.now)
    @favourites_count = data["favourites_count"].to_i
    @utc_offset = data["utc_offset"]
    @time_zone = data["time_zone"]
    @profile_background_image_url = data["profile_background_image_url"]
    @profile_background_tile = data["profile_background_tile"]
    @statuses_count = data["statuses_count"].to_i
    @notifications = data["notifications"]
    @following = data["following"]
    @status = StatusBasic.new(data["status"])
  else
    @created_at = DateTime.now
  end
end