Class: WpxmlParser::Blog
- Inherits:
-
Object
- Object
- WpxmlParser::Blog
- Defined in:
- lib/wpxml_parser/blog.rb
Instance Method Summary collapse
- #attachments ⇒ Object
- #find_post(post_id) ⇒ Object
-
#initialize(xml_filename) ⇒ Blog
constructor
A new instance of Blog.
- #posts ⇒ Object
Constructor Details
#initialize(xml_filename) ⇒ Blog
Returns a new instance of Blog.
6 7 8 9 10 |
# File 'lib/wpxml_parser/blog.rb', line 6 def initialize(xml_filename) File.open(xml_filename) do |xml_file| @xml = Nokogiri::XML(xml_file) end end |
Instance Method Details
#attachments ⇒ Object
22 23 24 25 26 |
# File 'lib/wpxml_parser/blog.rb', line 22 def @xml.xpath('//item').map do |item| Post.new(item) end.select{|p| p.post_type == 'attachment'} end |
#find_post(post_id) ⇒ Object
18 19 20 |
# File 'lib/wpxml_parser/blog.rb', line 18 def find_post(post_id) posts.find{|p| p.post_id == post_id} end |