Class: WordpRSS::Item

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

Instance Method Summary collapse

Constructor Details

#initialize(node) ⇒ Item

Returns a new instance of Item.



3
4
5
# File 'lib/wordprss/item.rb', line 3

def initialize(node)
  @node = node
end

Instance Method Details

#creatorString

Returns item author

Returns:

  • (String)


45
46
47
48
# File 'lib/wordprss/item.rb', line 45

def creator
  creator_node = node.elements.last.children.find { |c| c.name == "dc:creator" }
  creator_node.text if !creator_node.nil?
end

#descriptionString

Returns the item description

Returns:

  • (String)


31
32
33
# File 'lib/wordprss/item.rb', line 31

def description
  node.at("description").text
end

Returns the item link

Returns:

  • (String)


17
18
19
# File 'lib/wordprss/item.rb', line 17

def link
  node.at("link").text
end

#published_atString

Returns the item publication date

Returns:

  • (String)


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

def published_at
  node.at("pubDate").text
end

#tagsArray<String>

Returns an array of the item categories

Returns:

  • (Array<String>)


38
39
40
# File 'lib/wordprss/item.rb', line 38

def tags
  node.css("category").map(&:text)
end

#titleString

Returns the item title

Returns:

  • (String)


10
11
12
# File 'lib/wordprss/item.rb', line 10

def title
  node.at("title").text
end