Class: Net::Instagram::Models::User
- Inherits:
-
Object
- Object
- Net::Instagram::Models::User
- Defined in:
- lib/net/instagram/models/user.rb
Instance Attribute Summary collapse
-
#follower_count ⇒ Object
readonly
Returns the value of attribute follower_count.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Class Method Summary collapse
-
.find_by(params = {}) ⇒ Net::Instagram::Models::User?
Returns the existing Instagram user matching the provided attributes or nil when the user is not found.
-
.find_by!(params = {}) ⇒ Net::Instagram::Models::User
Returns the existing Instagram user matching the provided attributes or nil when the user is not found, and raises an error when the user account is private.
Instance Method Summary collapse
-
#initialize(attrs = {}) ⇒ User
constructor
A new instance of User.
Constructor Details
#initialize(attrs = {}) ⇒ User
Returns a new instance of User.
10 11 12 13 |
# File 'lib/net/instagram/models/user.rb', line 10 def initialize(attrs = {}) @username = attrs['username'] @follower_count = attrs['counts']['followed_by'] end |
Instance Attribute Details
#follower_count ⇒ Object (readonly)
Returns the value of attribute follower_count.
8 9 10 |
# File 'lib/net/instagram/models/user.rb', line 8 def follower_count @follower_count end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
8 9 10 |
# File 'lib/net/instagram/models/user.rb', line 8 def username @username end |
Class Method Details
.find_by(params = {}) ⇒ Net::Instagram::Models::User?
Returns the existing Instagram user matching the provided attributes or nil when the user is not found.
23 24 25 26 27 |
# File 'lib/net/instagram/models/user.rb', line 23 def self.find_by(params = {}) find_by! params rescue Errors::PrivateUser, Errors::UnknownUser nil end |
.find_by!(params = {}) ⇒ Net::Instagram::Models::User
Returns the existing Instagram user matching the provided attributes or nil when the user is not found, and raises an error when the user account is private.
39 40 41 42 43 44 45 |
# File 'lib/net/instagram/models/user.rb', line 39 def self.find_by!(params = {}) if params[:username] find_by_username! params[:username] elsif params[:id] find_by_id! params[:id] end end |