Class: Wordpressto::WordpressAttachment

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#conn

Constructor Details

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

Returns a new instance of WordpressAttachment.



80
81
82
83
84
85
86
# File 'lib/wordpressto.rb', line 80

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.



78
79
80
# File 'lib/wordpressto.rb', line 78

def file=(value)
  @file = value
end

#filenameObject

Returns the value of attribute filename.



78
79
80
# File 'lib/wordpressto.rb', line 78

def filename
  @filename
end

#mimetypeObject

Returns the value of attribute mimetype.



78
79
80
# File 'lib/wordpressto.rb', line 78

def mimetype
  @mimetype
end

#nameObject

Returns the value of attribute name.



78
79
80
# File 'lib/wordpressto.rb', line 78

def name
  @name
end

#urlObject

Returns the value of attribute url.



78
79
80
# File 'lib/wordpressto.rb', line 78

def url
  @url
end

Instance Method Details

#saveObject



88
89
90
91
92
# File 'lib/wordpressto.rb', line 88

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