Class: Instagram::User
- Inherits:
-
Object
- Object
- Instagram::User
- Defined in:
- lib/Instagram/user.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#language ⇒ Object
readonly
Returns the value of attribute language.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#session ⇒ Object
Returns the value of attribute session.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
- #api ⇒ Object
- #device_id ⇒ Object
- #dpi ⇒ Object
- #info ⇒ Object
-
#initialize(username, password, session = nil, data = nil) ⇒ User
constructor
A new instance of User.
- #md5 ⇒ Object
- #md5int ⇒ Object
- #release ⇒ string
- #resolution ⇒ Object
- #search_for_user(username) ⇒ Object
- #user_media(data = {}) ⇒ Object
- #useragent ⇒ Object
- #useragent_hash ⇒ Object
Constructor Details
#initialize(username, password, session = nil, data = nil) ⇒ User
Returns a new instance of User.
15 16 17 18 19 20 21 |
# File 'lib/Instagram/user.rb', line 15 def initialize(username, password, session = nil, data = nil) @username = username @password = password @language = 'en_US' @session = session @data = data end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
10 11 12 |
# File 'lib/Instagram/user.rb', line 10 def data @data end |
#language ⇒ Object (readonly)
Returns the value of attribute language.
9 10 11 |
# File 'lib/Instagram/user.rb', line 9 def language @language end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
8 9 10 |
# File 'lib/Instagram/user.rb', line 8 def password @password end |
#session ⇒ Object
Returns the value of attribute session.
12 13 14 |
# File 'lib/Instagram/user.rb', line 12 def session @session end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
7 8 9 |
# File 'lib/Instagram/user.rb', line 7 def username @username end |
Instance Method Details
#api ⇒ Object
39 40 41 |
# File 'lib/Instagram/user.rb', line 39 def api (18 + (md5int % 5)).to_s end |
#device_id ⇒ Object
80 81 82 |
# File 'lib/Instagram/user.rb', line 80 def device_id 'android-' + md5[0..15] end |
#dpi ⇒ Object
48 49 50 |
# File 'lib/Instagram/user.rb', line 48 def dpi %w[801 577 576 538 515 424 401 373][md5int % 8] end |
#info ⇒ Object
57 58 59 60 61 62 63 64 |
# File 'lib/Instagram/user.rb', line 57 def info line = Device.devices[md5int % Device.devices.count] { manufacturer: line[0], device: line[1], model: line[2] } end |
#md5 ⇒ Object
31 32 33 |
# File 'lib/Instagram/user.rb', line 31 def md5 Digest::MD5.hexdigest @username end |
#md5int ⇒ Object
35 36 37 |
# File 'lib/Instagram/user.rb', line 35 def md5int (md5.to_i(32) / 10e32).round end |
#release ⇒ string
44 45 46 |
# File 'lib/Instagram/user.rb', line 44 def release %w[4.0.4 4.3.1 4.4.4 5.1.1 6.0.1][md5int % 5] end |
#resolution ⇒ Object
52 53 54 55 |
# File 'lib/Instagram/user.rb', line 52 def resolution %w[3840x2160 1440x2560 2560x1440 1440x2560 2560x1440 1080x1920 1080x1920 1080x1920][md5int % 8] end |
#search_for_user(username) ⇒ Object
23 24 25 |
# File 'lib/Instagram/user.rb', line 23 def search_for_user (username) Instagram::Account.search_for_user(self, username) end |
#user_media(data = {}) ⇒ Object
27 28 29 |
# File 'lib/Instagram/user.rb', line 27 def user_media(data = {}) Instagram::Feed.user_media(self, data) end |
#useragent ⇒ Object
76 77 78 |
# File 'lib/Instagram/user.rb', line 76 def useragent format('Instagram %s Android(%s)', useragent_hash[:version], useragent_hash[:agent].rstrip) end |
#useragent_hash ⇒ Object
66 67 68 69 70 71 72 73 74 |
# File 'lib/Instagram/user.rb', line 66 def useragent_hash agent = [api + '/' + release, dpi + 'dpi', resolution, info[:manufacturer], info[:model], info[:device], @language] { agent: agent.join('; '), version: CONSTANTS::PRIVATE_KEY[:APP_VERSION] } end |