Class: Wordpress::WXR::Attachments
- Inherits:
-
Object
- Object
- Wordpress::WXR::Attachments
- Includes:
- Enumerable
- Defined in:
- lib/wordpress/wxr/attachments.rb
Instance Method Summary collapse
- #each ⇒ Object
- #find_by(id:) ⇒ Object
-
#initialize(document, wxr) ⇒ Attachments
constructor
A new instance of Attachments.
Constructor Details
#initialize(document, wxr) ⇒ Attachments
Returns a new instance of Attachments.
11 12 13 14 |
# File 'lib/wordpress/wxr/attachments.rb', line 11 def initialize(document, wxr) @document = document @wxr = wxr end |
Instance Method Details
#each ⇒ Object
16 17 18 19 20 21 22 |
# 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:) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/wordpress/wxr/attachments.rb', line 24 def find_by(id:) = nodes.xpath("wp:post_id[text() = '#{Integer(id)}']/parent::node()") return unless Attachment.new(, wxr) end |