Class: Preposterous::Post

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

client, establish_client, #getsites, #gettags, #newcomment, #newpost, #readposts, #updatepost

Constructor Details

#initialize(attributes = {}) ⇒ Post

Returns a new instance of Post.



6
7
8
# File 'lib/preposterous/post.rb', line 6

def initialize(attributes={})
  @media = []
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



3
4
5
# File 'lib/preposterous/post.rb', line 3

def attributes
  @attributes
end

#autopostObject

Returns the value of attribute autopost.



4
5
6
# File 'lib/preposterous/post.rb', line 4

def autopost
  @autopost
end

#bodyObject

Returns the value of attribute body.



4
5
6
# File 'lib/preposterous/post.rb', line 4

def body
  @body
end

#clientObject (readonly)

Returns the value of attribute client.



3
4
5
# File 'lib/preposterous/post.rb', line 3

def client
  @client
end

#dateObject

Returns the value of attribute date.



4
5
6
# File 'lib/preposterous/post.rb', line 4

def date
  @date
end

#mediaObject

Returns the value of attribute media.



4
5
6
# File 'lib/preposterous/post.rb', line 4

def media
  @media
end

#post_idObject

Returns the value of attribute post_id.



4
5
6
# File 'lib/preposterous/post.rb', line 4

def post_id
  @post_id
end

#privateObject

Returns the value of attribute private.



4
5
6
# File 'lib/preposterous/post.rb', line 4

def private
  @private
end

#site_idObject

Returns the value of attribute site_id.



4
5
6
# File 'lib/preposterous/post.rb', line 4

def site_id
  @site_id
end

#sourceObject

Returns the value of attribute source.



4
5
6
# File 'lib/preposterous/post.rb', line 4

def source
  @source
end

Returns the value of attribute sourceLink.



4
5
6
# File 'lib/preposterous/post.rb', line 4

def sourceLink
  @sourceLink
end

#tagsObject

Returns the value of attribute tags.



4
5
6
# File 'lib/preposterous/post.rb', line 4

def tags
  @tags
end

#titleObject

Returns the value of attribute title.



4
5
6
# File 'lib/preposterous/post.rb', line 4

def title
  @title
end

Instance Method Details

#is_new?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/preposterous/post.rb', line 21

def is_new?
  post_id.nil?
end

#saveObject



25
26
27
28
29
30
31
# File 'lib/preposterous/post.rb', line 25

def save
  if self.is_new?
    Preposterous::Base.client.newpost(attributes, *@media)
  else
    Preposterous::Base.client.updatepost(attributes, *@media)
  end
end