Class: Item

Inherits:
Object
  • Object
show all
Defined in:
lib/stanzas/notification_stanza.rb

Instance Method Summary collapse

Constructor Details

#initialize(node) ⇒ Item

Returns a new instance of Item.



107
108
109
# File 'lib/stanzas/notification_stanza.rb', line 107

def initialize(node)
  @node = node
end

Instance Method Details

#authorsObject



155
156
157
158
159
160
161
162
163
# File 'lib/stanzas/notification_stanza.rb', line 155

def authors
  if !@authors
    @authors = []
    @node.xpath("./atom:entry/atom:author", {"atom" => "http://www.w3.org/2005/Atom"}).each do |node|
      @authors.push(Author.new(node))
    end
  end
  @authors
end

#categoriesObject



165
166
167
168
169
170
171
172
173
# File 'lib/stanzas/notification_stanza.rb', line 165

def categories
  if !@categories
    @categories = []
    @node.xpath("./atom:entry/atom:category", {"atom" => "http://www.w3.org/2005/Atom"}).each do |node|
      @categories.push(Category.new(node))
    end
  end
  @categories
end

#chunkObject



141
142
143
# File 'lib/stanzas/notification_stanza.rb', line 141

def chunk
  @node["chunk"].to_i
end

#chunksObject



137
138
139
# File 'lib/stanzas/notification_stanza.rb', line 137

def chunks
  @node["chunks"].to_i
end


145
146
147
148
149
150
151
152
153
# File 'lib/stanzas/notification_stanza.rb', line 145

def links
  if !@links
    @links = []
    @node.xpath("./atom:entry/atom:link", {"atom" => "http://www.w3.org/2005/Atom"}).each do |node|
      @links.push(Link.new(node))
    end
  end
  @links
end

#locationsObject



175
176
177
178
179
180
181
182
183
# File 'lib/stanzas/notification_stanza.rb', line 175

def locations
  if !@locations
    @locations = []
    @node.xpath("./atom:entry/georss:point", {"atom" => "http://www.w3.org/2005/Atom", "georss" => "http://www.georss.org/georss"}).each do |node|
      @locations.push(Location.new(node))
    end
  end
  @locations
end

#publishedObject



128
129
130
131
132
133
134
135
# File 'lib/stanzas/notification_stanza.rb', line 128

def published
  if !@published
    if published = @node.at_xpath("./atom:entry/atom:published", {"atom" => "http://www.w3.org/2005/Atom"}).text
      @published = Time.parse(published)
    end
  end
  @published
end

#summaryObject



115
116
117
118
119
120
121
122
# File 'lib/stanzas/notification_stanza.rb', line 115

def summary
  if !@summary
    if summary = @node.at_xpath("./atom:entry/atom:summary", {"atom" => "http://www.w3.org/2005/Atom"})
      @summary = summary.text
    end
  end
  @summary
end

#titleObject



111
112
113
# File 'lib/stanzas/notification_stanza.rb', line 111

def title
  @title ||= @node.at_xpath("./atom:entry/atom:title", {"atom" => "http://www.w3.org/2005/Atom"}).text
end

#unique_idObject



124
125
126
# File 'lib/stanzas/notification_stanza.rb', line 124

def unique_id
  @unique_id ||= @node.at_xpath("./atom:entry/atom:id", {"atom" => "http://www.w3.org/2005/Atom"}).text
end