Class: Looks::Gravatar::Image

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/looks/gravatar/image.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, url, rating) ⇒ Image

Returns a new instance of Image.



29
30
31
32
33
# File 'lib/looks/gravatar/image.rb', line 29

def initialize(id, url, rating)
  @id     = id
  @url    = url
  @rating = rating
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



27
28
29
# File 'lib/looks/gravatar/image.rb', line 27

def id
  @id
end

#ratingObject

Returns the value of attribute rating.



27
28
29
# File 'lib/looks/gravatar/image.rb', line 27

def rating
  @rating
end

#urlObject

Returns the value of attribute url.



27
28
29
# File 'lib/looks/gravatar/image.rb', line 27

def url
  @url
end

Class Method Details

.new_from_addresses(value) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/looks/gravatar/image.rb', line 6

def self.new_from_addresses(value)
  id = value['userimage']

  if not id.empty?
    url    = value['userimage_url']
    rating = value['rating']

    new(id, url, rating)
  else
    nil
  end
end

.new_from_images(key, value) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/looks/gravatar/image.rb', line 19

def self.new_from_images(key, value)
  id     = key
  url    = value[1]
  rating = value[0]

  new(id, url, rating)
end

Instance Method Details

#<=>(other) ⇒ Object



35
36
37
# File 'lib/looks/gravatar/image.rb', line 35

def <=>(other)
  id <=> other.id
end

#to_sObject



39
40
41
# File 'lib/looks/gravatar/image.rb', line 39

def to_s
  id
end