Class: Ravelry::User

Inherits:
Data
  • Object
show all
Defined in:
lib/ravelry/user.rb

Overview

  • ‘user.pattern_author` (alias: `user.author`) - a Author object

  • ‘user.user_sites` - an array of UserSite objects

See the documentation for each object’s available methods.

Instance Attribute Summary collapse

Attributes inherited from Data

#data, #id

Instance Method Summary collapse

Methods inherited from Data

#initialize

Constructor Details

This class inherits a constructor from Ravelry::Data

Instance Attribute Details

#pattern_authorObject (readonly)

Returns the value of attribute pattern_author.



58
59
60
# File 'lib/ravelry/user.rb', line 58

def pattern_author
  @pattern_author
end

#user_sitesObject (readonly)

Returns the value of attribute user_sites.



58
59
60
# File 'lib/ravelry/user.rb', line 58

def user_sites
  @user_sites
end

Instance Method Details

#_idObject

ID from the Ravelry database.



119
120
121
# File 'lib/ravelry/user.rb', line 119

def _id
  @data[:id]
end

#about_meObject



69
70
71
# File 'lib/ravelry/user.rb', line 69

def about_me
  @data[:about_me]
end

#about_me_htmlObject



73
74
75
# File 'lib/ravelry/user.rb', line 73

def about_me_html
  @data[:about_me_html]
end

#authorObject



77
78
79
# File 'lib/ravelry/user.rb', line 77

def author
  @pattern_author
end

#fave_colorsObject



81
82
83
# File 'lib/ravelry/user.rb', line 81

def fave_colors
  @data[:fave_colors]
end

#fave_curseObject



85
86
87
# File 'lib/ravelry/user.rb', line 85

def fave_curse
  @data[:fave_curse]
end

#first_nameObject



89
90
91
# File 'lib/ravelry/user.rb', line 89

def first_name
  @data[:first_name]
end

#getObject



60
61
62
63
64
65
66
67
# File 'lib/ravelry/user.rb', line 60

def get
  request = Typhoeus::Request.get("https://api.ravelry.com/people/#{@id}.json", userpwd: "#{Ravelry.configuration.access_key}:#{Ravelry.configuration.personal_key}")
  result = JSON.parse(request.response_body, {symbolize_names: true})
  @data = result[:user]
  @pattern_author = Build.author(@data)
  @user_sites = Build.user_sites(@data)
  self
end

#large_photo_urlObject



93
94
95
# File 'lib/ravelry/user.rb', line 93

def large_photo_url
  @data[:large_photo_url]
end

#locationObject



97
98
99
# File 'lib/ravelry/user.rb', line 97

def location
  @data[:location]
end

#photo_urlObject



101
102
103
# File 'lib/ravelry/user.rb', line 101

def photo_url
  @data[:photo_url]
end

#small_photo_urlObject



105
106
107
# File 'lib/ravelry/user.rb', line 105

def small_photo_url
  @data[:small_photo_url]
end

#tiny_photo_urlObject



109
110
111
# File 'lib/ravelry/user.rb', line 109

def tiny_photo_url
  @data[:tiny_photo_url]
end

#usernameObject



113
114
115
# File 'lib/ravelry/user.rb', line 113

def username
  @data[:username]
end