class Wordpress::WXR::Attachments

Attributes

document[R]
wxr[R]

Public Class Methods

new(document, wxr) click to toggle source
# File lib/wordpress/wxr/attachments.rb, line 11
def initialize(document, wxr)
  @document = document
  @wxr = wxr
end

Public Instance Methods

each() { |attachment| ... } click to toggle source
# File lib/wordpress/wxr/attachments.rb, line 16
def each
  return enum_for(:each) unless block_given?

  nodes.each do |node|
    yield Attachment.new(node, wxr)
  end
end
find_by(id:) click to toggle source
# File lib/wordpress/wxr/attachments.rb, line 24
def find_by(id:)
  attachment = nodes.xpath("wp:post_id[text() = '#{Integer(id)}']/parent::node()")
  return unless attachment

  Attachment.new(attachment, wxr)
end

Private Instance Methods

nodes() click to toggle source
# File lib/wordpress/wxr/attachments.rb, line 33
def nodes
  document.xpath("//item[wp:post_type = 'attachment']")
end