Class: WpRpc::Attachment

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#change_attributes, #conn, #pattern

Constructor Details

#initialize(attributes, options = { }) ⇒ Attachment

Returns a new instance of Attachment.



6
7
8
9
10
11
12
# File 'lib/wp_rpc/attachment.rb', line 6

def initialize(attributes, options = { })
  super(options)
  self.name = attributes[:name]
  self.filename = attributes[:filename]
  self.mimetype = attributes[:mimetype]
  self.file = attributes[:file]
end

Instance Attribute Details

#file=(value) ⇒ Object

Sets the attribute file

Parameters:

  • value

    the value to set the attribute file to.



4
5
6
# File 'lib/wp_rpc/attachment.rb', line 4

def file=(value)
  @file = value
end

#filenameObject

Returns the value of attribute filename.



4
5
6
# File 'lib/wp_rpc/attachment.rb', line 4

def filename
  @filename
end

#mimetypeObject

Returns the value of attribute mimetype.



4
5
6
# File 'lib/wp_rpc/attachment.rb', line 4

def mimetype
  @mimetype
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/wp_rpc/attachment.rb', line 4

def name
  @name
end

#urlObject

Returns the value of attribute url.



4
5
6
# File 'lib/wp_rpc/attachment.rb', line 4

def url
  @url
end

Instance Method Details

#saveObject



14
15
16
17
18
# File 'lib/wp_rpc/attachment.rb', line 14

def save
  ret = conn.upload_file(name, mimetype, bits)
  self.url = ret["url"]
  self
end