Method: Ayadn::UserObject#initialize
- Defined in:
- lib/ayadn/user_object.rb
#initialize(hash, username = nil) ⇒ UserObject
Returns a new instance of UserObject.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/ayadn/user_object.rb', line 84 def initialize hash, username = nil @input = hash['data'].nil? ? hash : hash['data'] @meta = UserMetaObject.new(hash, username) @you_muted = @input["you_muted"] @you_can_subscribe = @input["you_can_subscribe"] @is_follower = @input["is_follower"] @is_following = @input["is_following"] @timezone = @input["timezone"] @you_follow = @input["you_follow"] @counts = UserCountsObject.new(@input) unless @input.empty? @canonical_url = @input["canonical_url"] @id = @input["id"] @locale = @input["locale"] @type = @input["type"] if !@input["annotations"].nil? @annotations = @input["annotations"].map { |hash| UserAnnotationObject.new(hash) } else @annotations = [] end @username = @input["username"] @avatar_image = AvatarImageObject.new(@input) unless @input.empty? @description = UserDescriptionObject.new(@input) unless @input.empty? @is_muted = @input["is_muted"] @follows_you = @input["follows_you"] @you_can_follow = @input["you_can_follow"] @name = @input["name"].to_s.force_encoding("UTF-8") @created_at = @input["created_at"] @you_blocked = @input["you_blocked"] @cover_image = CoverImageObject.new(@input) unless @input.empty? @verified_domain = @input["verified_domain"] end |