Class: Yarss::Item

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

Overview

Feed item data holder.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = nil) ⇒ Item

Returns a new instance of Item.

Parameters:

  • attributes (Hash, nil) (defaults to: nil)

    Data to set.



32
33
34
35
36
37
# File 'lib/yarss/item.rb', line 32

def initialize(attributes = nil)
  attributes.each do |attribute, value|
    setter = "#{attribute}="
    send(setter, value)
  end if attributes
end

Instance Attribute Details

#contentString

Content.

Returns:

  • (String)


29
30
31
# File 'lib/yarss/item.rb', line 29

def content
  @content
end

#idString

ID.

Returns:

  • (String)


9
10
11
# File 'lib/yarss/item.rb', line 9

def id
  @id
end

URL to the related Web page.

Returns:

  • (String)


24
25
26
# File 'lib/yarss/item.rb', line 24

def link
  @link
end

#titleString

Title.

Returns:

  • (String)


14
15
16
# File 'lib/yarss/item.rb', line 14

def title
  @title
end

#updated_atDateTime

Date and time of the last modification.

Returns:

  • (DateTime)


19
20
21
# File 'lib/yarss/item.rb', line 19

def updated_at
  @updated_at
end

Instance Method Details

#==(other) ⇒ Bool

Treat this class as a value object.

Parameters:

Returns:

  • (Bool)


44
45
46
47
48
49
50
51
52
# File 'lib/yarss/item.rb', line 44

def ==(other) # rubocop:disable Metrics/AbcSize
  return false unless other.is_a?(self.class)

  id           == other.id         &&
    title      == other.title      &&
    updated_at == other.updated_at &&
    link       == other.link       &&
    content    == other.content
end