Class: WordpressImport::Attachment

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node) ⇒ Attachment

Returns a new instance of Attachment.



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/wordpress_import/attachment.rb', line 5

def initialize(node)
  @id = node.xpath('wp:post_id').first.content.to_i
  @parent = node.xpath('wp:post_parent').first.content
  @url = node.xpath('wp:attachment_url').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

  @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

#creatorObject

Returns the value of attribute creator.



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

def creator
  @creator
end

#dateObject

Returns the value of attribute date.



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

def date
  @date
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#metaObject

Returns the value of attribute meta.



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

def meta
  @meta
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#parentObject

Returns the value of attribute parent.



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

def parent
  @parent
end

#urlObject

Returns the value of attribute url.



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

def url
  @url
end