class Wordpress::WXR::Categories

Attributes

document[R]
wxr[R]

Public Class Methods

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

Public Instance Methods

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

  nodes.each do |node|
    yield Category.new(node, wxr)
  end
end
find_by(nicename:) click to toggle source
# File lib/wordpress/wxr/categories.rb, line 24
def find_by(nicename:)
  return if nicename.empty?

  category = nodes.xpath("wp:category_nicename[text() = '#{nicename}']/parent::node()")
  return unless category

  Category.new(category, wxr)
end

Private Instance Methods

nodes() click to toggle source
# File lib/wordpress/wxr/categories.rb, line 35
def nodes
  document.xpath('//wp:category')
end