Class: Contentful::Exporter::Wordpress::PostAttachment

Inherits:
Post
  • Object
show all
Defined in:
lib/wordpress/post_attachment.rb

Instance Attribute Summary collapse

Attributes inherited from Post

#xml

Attributes inherited from Blog

#xml

Instance Method Summary collapse

Methods inherited from Post

#post_extractor, #post_id

Methods inherited from Blog

#blog_extractor, #create_directory, #link_asset, #link_entry, #output_logger, #write_json_to_file

Constructor Details

#initialize(post, settings) ⇒ PostAttachment

Returns a new instance of PostAttachment.



9
10
11
12
# File 'lib/wordpress/post_attachment.rb', line 9

def initialize(post, settings)
  @post = post
  @settings = settings
end

Instance Attribute Details

#postObject (readonly)

Returns the value of attribute post.



7
8
9
# File 'lib/wordpress/post_attachment.rb', line 7

def post
  @post
end

#settingsObject (readonly)

Returns the value of attribute settings.



7
8
9
# File 'lib/wordpress/post_attachment.rb', line 7

def settings
  @settings
end

Instance Method Details

#attachment_extractorObject



14
15
16
17
18
19
20
21
# File 'lib/wordpress/post_attachment.rb', line 14

def attachment_extractor
  create_directory("#{settings.assets_dir}/attachment_post")
  asset = { id: attachment_id, description: attachment_description, url: attachment_url }
  unless asset[:url].nil?
    write_json_to_file("#{settings.assets_dir}/attachment_post/#{attachment_id}.json", asset)
    asset
  end
end