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.



37
38
39
40
41
42
# File 'lib/yarss/item.rb', line 37

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

Instance Attribute Details

#authorString

Author.

Returns:

  • (String)


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

def author
  @author
end

#contentString

Content.

Returns:

  • (String)


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

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)


49
50
51
52
53
54
55
56
57
58
# File 'lib/yarss/item.rb', line 49

def ==(other)
  return false unless other.is_a?(self.class)

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

#author?Bool

Is the author present?

Returns:

  • (Bool)


91
92
93
# File 'lib/yarss/item.rb', line 91

def author?
  !author.nil? && !author.empty?
end

#content?Bool

Is the content present?

Returns:

  • (Bool)


98
99
100
# File 'lib/yarss/item.rb', line 98

def content?
  !content.nil? && !content.empty?
end

#id?Bool

Is the ID present?

Returns:

  • (Bool)


63
64
65
# File 'lib/yarss/item.rb', line 63

def id?
  !id.nil? && !id.empty?
end

#link?Bool

Is the URL to the related Web page present?

Returns:

  • (Bool)


84
85
86
# File 'lib/yarss/item.rb', line 84

def link?
  !link.nil? && !link.empty?
end

#title?Bool

Is the title present?

Returns:

  • (Bool)


70
71
72
# File 'lib/yarss/item.rb', line 70

def title?
  !title.nil? && !title.empty?
end

#updated_at?Bool

Is the date and time of the last modification present?

Returns:

  • (Bool)


77
78
79
# File 'lib/yarss/item.rb', line 77

def updated_at?
  !updated_at.nil?
end