Class: WordpressImport::Post

Inherits:
Object
  • Object
show all
Defined in:
lib/wordpress_import/post.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node) ⇒ Post

Returns a new instance of Post.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/wordpress_import/post.rb', line 5

def initialize(node)
  @id = node.xpath('wp:post_id').first.content
  @parent = node.xpath('wp:post_parent').first.content
  @link = node.xpath('link').first.content
  @date = node.xpath('wp:post_date').first.content
  @creator = node.xpath('dc:creator').first.content
  @name = node.xpath('wp:post_name').first.content
  @status = node.xpath('wp:status').first.content

  @title = node.xpath('title').first.content
  @content = node.xpath('content:encoded').first.content
  @excerpt = node.xpath('excerpt:encoded').first.content

  @tags = node.xpath('category[@domain="post_tag"]').map { |t| t.attr('nicename') }
  @categories = node.xpath('category[@domain="category"]').map { |t| t.attr('nicename') }
  @meta = {}
  node.xpath('wp:postmeta').each do ||
    @meta[.xpath('wp:meta_key').first.content] = .xpath('wp:meta_value').first.content
  end
end

Instance Attribute Details

#categoriesObject

Returns the value of attribute categories.



3
4
5
# File 'lib/wordpress_import/post.rb', line 3

def categories
  @categories
end

#contentObject

Returns the value of attribute content.



3
4
5
# File 'lib/wordpress_import/post.rb', line 3

def content
  @content
end

#creatorObject

Returns the value of attribute creator.



3
4
5
# File 'lib/wordpress_import/post.rb', line 3

def creator
  @creator
end

#dateObject

Returns the value of attribute date.



3
4
5
# File 'lib/wordpress_import/post.rb', line 3

def date
  @date
end

#excerptObject

Returns the value of attribute excerpt.



3
4
5
# File 'lib/wordpress_import/post.rb', line 3

def excerpt
  @excerpt
end

#idObject

Returns the value of attribute id.



3
4
5
# File 'lib/wordpress_import/post.rb', line 3

def id
  @id
end

Returns the value of attribute link.



3
4
5
# File 'lib/wordpress_import/post.rb', line 3

def link
  @link
end

#metaObject

Returns the value of attribute meta.



3
4
5
# File 'lib/wordpress_import/post.rb', line 3

def meta
  @meta
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/wordpress_import/post.rb', line 3

def name
  @name
end

#parentObject

Returns the value of attribute parent.



3
4
5
# File 'lib/wordpress_import/post.rb', line 3

def parent
  @parent
end

#statusObject

Returns the value of attribute status.



3
4
5
# File 'lib/wordpress_import/post.rb', line 3

def status
  @status
end

#tagsObject

Returns the value of attribute tags.



3
4
5
# File 'lib/wordpress_import/post.rb', line 3

def tags
  @tags
end

#titleObject

Returns the value of attribute title.



3
4
5
# File 'lib/wordpress_import/post.rb', line 3

def title
  @title
end