Class: Gravatar
- Inherits:
-
Object
- Object
- Gravatar
- Defined in:
- lib/gravatar.rb
Constant Summary collapse
- DefaultOptions =
px
{:size => 80}
Instance Attribute Summary collapse
-
#border ⇒ Object
Returns the value of attribute border.
-
#default ⇒ Object
Returns the value of attribute default.
-
#id ⇒ Object
Returns the value of attribute id.
-
#rating ⇒ Object
Returns the value of attribute rating.
-
#size ⇒ Object
Returns the value of attribute size.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(email = '', options = {}) ⇒ Gravatar
constructor
A new instance of Gravatar.
- #to_s ⇒ Object
Constructor Details
#initialize(email = '', options = {}) ⇒ Gravatar
Returns a new instance of Gravatar.
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/gravatar.rb', line 8 def initialize(email = '', = {}) = DefaultOptions.merge() @id = Digest::MD5.hexdigest(email) @url = 'http://gravatar.com/avatar.php?gravatar_id=' + @id .each {|k,v| @url += "&#{k}=#{v}" unless v.nil?} %w(size rating border default).each do |a| instance_variable_set "@#{a}", [a.to_sym] end end |
Instance Attribute Details
#border ⇒ Object
Returns the value of attribute border.
6 7 8 |
# File 'lib/gravatar.rb', line 6 def border @border end |
#default ⇒ Object
Returns the value of attribute default.
6 7 8 |
# File 'lib/gravatar.rb', line 6 def default @default end |
#id ⇒ Object
Returns the value of attribute id.
6 7 8 |
# File 'lib/gravatar.rb', line 6 def id @id end |
#rating ⇒ Object
Returns the value of attribute rating.
6 7 8 |
# File 'lib/gravatar.rb', line 6 def @rating end |
#size ⇒ Object
Returns the value of attribute size.
6 7 8 |
# File 'lib/gravatar.rb', line 6 def size @size end |
#url ⇒ Object
Returns the value of attribute url.
6 7 8 |
# File 'lib/gravatar.rb', line 6 def url @url end |
Instance Method Details
#to_s ⇒ Object
21 |
# File 'lib/gravatar.rb', line 21 def to_s; url; end |