Class: Delicious::Link

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

Overview

Collector Class end #############

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text, url, posted_by, people, tags) ⇒ Link

Returns a new instance of Link.



103
104
105
106
107
108
109
# File 'lib/delicious.rb', line 103

def initialize(text, url, posted_by, people, tags)
  @text = text
  @url = url
  @posted_by = posted_by
  @people = people
  @tags = tags		
end

Instance Attribute Details

#peopleObject (readonly)

Returns the value of attribute people.



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

def people
  @people
end

#posted_byObject (readonly)

Returns the value of attribute posted_by.



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

def posted_by
  @posted_by
end

#tagsObject (readonly)

Returns the value of attribute tags.



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

def tags
  @tags
end

#textObject (readonly)

Returns the value of attribute text.



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

def text
  @text
end

#urlObject (readonly)

Returns the value of attribute url.



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

def url
  @url
end

Instance Method Details

#<=>(link) ⇒ Object

Comparator method. The links should be ordered by the number of people that saved them.



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

def <=> (link)      
  if @people > link.people
    return 1
  elsif @people < link.people
    return -1
  end      
  0      
end

#equal?(link) ⇒ Boolean

Returns:

  • (Boolean)


121
122
123
# File 'lib/delicious.rb', line 121

def equal?(link)     
  link.url == @url
end