Class: Yarss::Feed

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

Overview

Feed data holder.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = nil) ⇒ Feed

Returns a new instance of Feed.

Parameters:

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

    Data to set.



27
28
29
30
31
32
# File 'lib/yarss/feed.rb', line 27

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

Instance Attribute Details

#descriptionString

Description.

Returns:

  • (String)


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

def description
  @description
end

#itemsArray<Item>

Feed items.

Returns:



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

def items
  @items
end

URL to the related Web page.

Returns:

  • (String)


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

def link
  @link
end

#titleString

Title.

Returns:

  • (String)


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

def title
  @title
end

Instance Method Details

#==(other) ⇒ Bool

Treat this class as a value object.

Parameters:

Returns:

  • (Bool)


39
40
41
42
43
44
45
46
# File 'lib/yarss/feed.rb', line 39

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

  title         == other.title       &&
    link        == other.link        &&
    description == other.description &&
    items       == other.items
end

#description?Bool

Is the description present?

Returns:

  • (Bool)


65
66
67
# File 'lib/yarss/feed.rb', line 65

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

#items?Bool

Are the feed items present?

Returns:

  • (Bool)


72
73
74
# File 'lib/yarss/feed.rb', line 72

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

#link?Bool

Is the URL to the related Web page present?

Returns:

  • (Bool)


58
59
60
# File 'lib/yarss/feed.rb', line 58

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

#title?Bool

Is the title present?

Returns:

  • (Bool)


51
52
53
# File 'lib/yarss/feed.rb', line 51

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