class Item
Attributes
doc[RW]
file[RW]
status[RW]
timestamp[RW]
title[RW]
Public Class Methods
new(xml, filename)
click to toggle source
# File lib/abelard/dir.rb, line 15 def initialize(xml, filename) @doc = xml @file = filename timestamp_node = doc.find_first("/atom:entry/atom:published", NS) || doc.find_first("/item/pubDate") if timestamp_node @timestamp = Time.parse(timestamp_node.content) else @timestamp = Time.new(0) end title_node = doc.find_first("/atom:entry/atom:title", NS) || doc.find_first("/item/title") if title_node @title = title_node.content else @title = "Post" end author_node = doc.find_first("/atom:entry/atom:author/atom:name", NS) || doc.find_first("/item/dc:creator", NS) if author_node @author = author_node.content else @author = 'abelard' end @status = :published status_node = doc.find_first("/item/wp:status", NS) if status_node $stderr.puts("raw status #{status_node.content}") if status_node.content == "trash" @status = :trash elsif status_node.content == "draft" @status = :draft end end draft_node = doc.find_first("/atom:entry/app:control/app:draft", NS) if draft_node if draft_node.content == "yes" @status = :draft end end end
Public Instance Methods
save()
click to toggle source
# File lib/abelard/dir.rb, line 61 def save puts("writing #{file}") doc.save(file, :indent => true, :encoding => LibXML::XML::Encoding::UTF_8) end