Class: Badges::Treehouse

Inherits:
Badge
  • Object
show all
Defined in:
lib/badges.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(profile_name) ⇒ Treehouse

Returns a new instance of Treehouse.



81
82
83
84
85
86
# File 'lib/badges.rb', line 81

def initialize(profile_name)
  @profile_name = profile_name
  @profile_url = 'http://teamtreehouse.com/' + @profile_name
  
  @response = get(@profile_url + '.json')
end

Instance Attribute Details

#profile_nameObject (readonly)

Returns the value of attribute profile_name.



79
80
81
# File 'lib/badges.rb', line 79

def profile_name
  @profile_name
end

#profile_urlObject (readonly)

Returns the value of attribute profile_url.



79
80
81
# File 'lib/badges.rb', line 79

def profile_url
  @profile_url
end

Instance Method Details

#badgesObject



88
89
90
91
92
93
94
# File 'lib/badges.rb', line 88

def badges
  begin
    @response['badges']
  rescue
    nil
  end
end

#gravatar_urlObject



96
97
98
99
100
101
102
# File 'lib/badges.rb', line 96

def gravatar_url
  begin
    @response['gravatar_url']
  rescue
    nil
  end
end

#nameObject



104
105
106
107
108
109
110
# File 'lib/badges.rb', line 104

def name
  begin
    @response['name']
  rescue
    nil
  end
end

#pointsObject



112
113
114
115
116
117
118
# File 'lib/badges.rb', line 112

def points
  begin
    @response['points']
  rescue
    nil
  end
end

#points_totalObject



120
121
122
123
124
125
126
# File 'lib/badges.rb', line 120

def points_total
  begin
    @response['points']['total']
  rescue
    nil
  end
end