Class: Headline

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title, url, channel = '') ⇒ Headline

Returns a new instance of Headline.



4
5
6
7
8
# File 'lib/headline.rb', line 4

def initialize(title, url, channel = '')
  @title = title
  @url = url
  @channel = channel
end

Instance Attribute Details

#channelObject (readonly)

Returns the value of attribute channel.



2
3
4
# File 'lib/headline.rb', line 2

def channel
  @channel
end

#titleObject (readonly)

Returns the value of attribute title.



2
3
4
# File 'lib/headline.rb', line 2

def title
  @title
end

#urlObject (readonly)

Returns the value of attribute url.



2
3
4
# File 'lib/headline.rb', line 2

def url
  @url
end

Instance Method Details

#==(other) ⇒ Object



10
11
12
13
# File 'lib/headline.rb', line 10

def ==(other)
  !other.nil? && other.is_a?(Headline) && @title == other.title &&
    @url == other.url && @channel == other.channel
end

#to_sObject



15
16
17
# File 'lib/headline.rb', line 15

def to_s
  "#{title} [#{url}]"
end