Class: Yarss::Item
- Inherits:
-
Object
- Object
- Yarss::Item
- Defined in:
- lib/yarss/item.rb
Overview
Feed item data holder.
Instance Attribute Summary collapse
-
#author ⇒ String
Author.
-
#content ⇒ String
Content.
-
#id ⇒ String
ID.
-
#link ⇒ String
URL to the related Web page.
-
#title ⇒ String
Title.
-
#updated_at ⇒ DateTime
Date and time of the last modification.
Instance Method Summary collapse
-
#==(other) ⇒ Bool
Treat this class as a value object.
-
#author? ⇒ Bool
Is the author present?.
-
#content? ⇒ Bool
Is the content present?.
-
#id? ⇒ Bool
Is the ID present?.
-
#initialize(attributes = nil) ⇒ Item
constructor
A new instance of Item.
-
#link? ⇒ Bool
Is the URL to the related Web page present?.
-
#title? ⇒ Bool
Is the title present?.
-
#updated_at? ⇒ Bool
Is the date and time of the last modification present?.
Constructor Details
#initialize(attributes = nil) ⇒ Item
Returns a new instance of Item.
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
#author ⇒ String
Author.
29 30 31 |
# File 'lib/yarss/item.rb', line 29 def end |
#content ⇒ String
Content.
34 35 36 |
# File 'lib/yarss/item.rb', line 34 def content @content end |
#id ⇒ String
ID.
9 10 11 |
# File 'lib/yarss/item.rb', line 9 def id @id end |
#link ⇒ String
URL to the related Web page.
24 25 26 |
# File 'lib/yarss/item.rb', line 24 def link @link end |
#title ⇒ String
Title.
14 15 16 |
# File 'lib/yarss/item.rb', line 14 def title @title end |
#updated_at ⇒ DateTime
Date and time of the last modification.
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.
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 && == other. && content == other.content end |
#author? ⇒ Bool
Is the author present?
91 92 93 |
# File 'lib/yarss/item.rb', line 91 def !.nil? && !.empty? end |
#content? ⇒ Bool
Is the content present?
98 99 100 |
# File 'lib/yarss/item.rb', line 98 def content? !content.nil? && !content.empty? end |
#id? ⇒ Bool
Is the ID present?
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?
84 85 86 |
# File 'lib/yarss/item.rb', line 84 def link? !link.nil? && !link.empty? end |
#title? ⇒ Bool
Is the title present?
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?
77 78 79 |
# File 'lib/yarss/item.rb', line 77 def updated_at? !updated_at.nil? end |