Class: Compostr::ImageUpload

Inherits:
Object
  • Object
show all
Defined in:
lib/compostr/image_upload.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_path, post_id = nil) ⇒ ImageUpload

Returns a new instance of ImageUpload.



7
8
9
10
11
# File 'lib/compostr/image_upload.rb', line 7

def initialize file_path, post_id=nil
  # TODO decide on getMediaLibrary to find an already uploaded image
  @file_path = file_path
  @post_id   = post_id
end

Instance Attribute Details

#file_pathObject

Returns the value of attribute file_path.



5
6
7
# File 'lib/compostr/image_upload.rb', line 5

def file_path
  @file_path
end

#post_idObject

Returns the value of attribute post_id.



5
6
7
# File 'lib/compostr/image_upload.rb', line 5

def post_id
  @post_id
end

Instance Method Details

#do_upload!Object

Push data to Wordpress instance, return attachment_id



14
15
16
17
18
# File 'lib/compostr/image_upload.rb', line 14

def do_upload!
  data = create_data
  response = Compostr::wp.uploadFile(data: data)
  response["attachment_id"]
end