Class: Tumble::Blog

Inherits:
Object
  • Object
show all
Defined in:
lib/tumble/blog.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection, name) ⇒ Blog

Returns a new instance of Blog.



3
4
5
6
# File 'lib/tumble/blog.rb', line 3

def initialize(connection, name)
  @connection = connection
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/tumble/blog.rb', line 8

def name
  @name
end

Instance Method Details

#avatar(options = {}) ⇒ Object

You can get a blog’s avatar in 9 different sizes. The default size is 64x64.

Parameters:

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :size (Integer)

    The size of the avatar. Must be in 16, 24, 30, 40, 48, 64, 96, 128, or 512

See Also:



26
27
28
# File 'lib/tumble/blog.rb', line 26

def avatar(options={})
  @connection.get("/blog/#{name}/avatar", options).response
end

#create_post(options = {}) ⇒ Object

Create a New Blog Post

For text posts: For photo posts: For quote posts: For link posts: For chat posts: For audio posts: For video posts:

Parameters:

  • options (Hash) (defaults to: {})

    A customizable set of options

Options Hash (options):

  • :type (String, required)

    The type of post to create. Specify one of the following: text, photo, quote, link, chat, audio, video

  • :state (String)

    The state of the post. Specify one of the following: published, draft, queue

  • :tags (String)

    Comma-separated tags for this post

  • :tweet (String)

    Manages the autotweet (if enabled) for this post: set to off for no tweet, or enter text to override the default tweet

  • :date (String)

    The GMT date and time of the post, as a string

  • :markdown (Boolean)

    Indicates whether the post uses markdown syntax

  • :slug (String)

    Add a short text summary to the end of the post URL

  • :title (String)

    The optional title of the post, HTML entities must be escaped

  • :body (String, required)

    The full post body, HTML allowed

  • :caption (String)

    The user-supplied caption, HTML allowed

  • :link (String)

    The “click-through URL” for the photo

  • :source (String, required)

    The photo source URL

  • :data (Array, required)

    One or more image files (submit multiple times to create a slide show)

  • :quote (String, required)

    The full text of the quote, HTML entities must be escaped

  • :source (String)

    Cited source, HTML allowed

  • :title (String)

    The title of the page the link points to, HTML entities should be escaped

  • :url (String, required)

    The link

  • :description (String)

    A user-supplied description, HTML allowed

  • :title (String)

    The title of the chat

  • :conversation (String, required)

    The text of the conversation/chat, with dialogue labels (no HTML)

  • :caption (String)

    The user-supplied caption

  • :external_url (String, required)

    The URL of the site that hosts the audio file (not tumblr)

  • :data (String, required)

    An audio file

  • :caption (String)

    The user-supplied caption

  • :embed (String, required)

    HTML embed code for the video

  • :data (String, required)

    A video file

See Also:



123
124
125
# File 'lib/tumble/blog.rb', line 123

def create_post(options={})
  @connection.post("/blog/#{name}/post", options).response
end

#delete_post(id) ⇒ Object

Delete a Post

Parameters:

  • id (Integer)

    The ID of the post to delete

See Also:



191
192
193
# File 'lib/tumble/blog.rb', line 191

def delete_post(id)
  @connection.post("/blog/#{name}/post/delete", :id => id).response
end

#draftsObject

Retreive Draft Posts



72
73
74
# File 'lib/tumble/blog.rb', line 72

def drafts
  @connection.get("/blog/#{name}/posts/draft").response
end

#edit_post(id, options = {}) ⇒ Object

Edit a Blog Post

For text posts: For photo posts: For quote posts: For link posts: For chat posts: For audio posts: For video posts:

Parameters:

  • id (Integer)

    The ID of the post to edit

  • options (Hash) (defaults to: {})

    A customizable set of options

Options Hash (options):

  • :type (String)

    The type of post to create. Specify one of the following: text, photo, quote, link, chat, audio, video

  • :state (String)

    The state of the post. Specify one of the following: published, draft, queue

  • :tags (String)

    Comma-separated tags for this post

  • :tweet (String)

    Manages the autotweet (if enabled) for this post: set to off for no tweet, or enter text to override the default tweet

  • :date (String)

    The GMT date and time of the post, as a string

  • :markdown (Boolean)

    Indicates whether the post uses markdown syntax

  • :slug (String)

    Add a short text summary to the end of the post URL

  • :title (String)

    The optional title of the post, HTML entities must be escaped

  • :body (String)

    The full post body, HTML allowed

  • :caption (String)

    The user-supplied caption, HTML allowed

  • :link (String)

    The “click-through URL” for the photo

  • :source (String)

    The photo source URL

  • :data (Array)

    One or more image files (submit multiple times to create a slide show)

  • :quote (String)

    The full text of the quote, HTML entities must be escaped

  • :source (String)

    Cited source, HTML allowed

  • :title (String)

    The title of the page the link points to, HTML entities should be escaped

  • :url (String)

    The link

  • :description (String)

    A user-supplied description, HTML allowed

  • :title (String)

    The title of the chat

  • :conversation (String)

    The text of the conversation/chat, with dialogue labels (no HTML)

  • :caption (String)

    The user-supplied caption

  • :external_url (String)

    The URL of the site that hosts the audio file (not tumblr)

  • :data (String)

    An audio file

  • :caption (String)

    The user-supplied caption

  • :embed (String)

    HTML embed code for the video

  • :data (String)

    A video file

See Also:



168
169
170
# File 'lib/tumble/blog.rb', line 168

def edit_post(id, options={})
  @connection.post("/blog/#{name}/post/edit", options.merge('id' => id)).response
end

#followers(options = {}) ⇒ Object

Retrieve a Blog’s Followers

Parameters:

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :limit (Integer)

    The number of results to return: 1–20, inclusive

  • :offset (Integer)

    Result to start at

See Also:



38
39
40
# File 'lib/tumble/blog.rb', line 38

def followers(options={})
  @connection.get("/blog/#{name}/followers", options).response
end

#infoObject

This method returns general information about the blog, such as the title, number of posts, and other high-level data.



15
16
17
# File 'lib/tumble/blog.rb', line 15

def info
  @connection.get("/blog/#{name}/info").response
end

#posts(options = {}) ⇒ Object

Retrieve Published Posts

Parameters:

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :type (String)

    The type of post to return. Specify one of the following: text, quote, link, answer, video, audio, photo

  • :id (Integer)

    A specific post ID. Returns the single post specified or (if not found) a 404 error.

  • :tag (String)

    Limits the response to posts with the specified tag

  • :limit (Integer)

    The number of posts to return: 1–20, inclusive

  • :offset (Integer)

    Post number to start at

  • :reblog_info (Boolean)

    Indicates whether to return reblog information (specify true or false). Returns the various reblogged_ fields.

  • :notes_info (Boolean)

    Indicates whether to return notes information (specify true or false). Returns note count and note metadata.

  • :format (String)

    Specifies the post format to return, other than HTML. Must be either text or raw.

See Also:



56
57
58
# File 'lib/tumble/blog.rb', line 56

def posts(options={})
  @connection.get("/blog/#{name}/posts", options).response
end

#queueObject

Retrieve Queued Posts



64
65
66
# File 'lib/tumble/blog.rb', line 64

def queue
  @connection.get("/blog/#{name}/posts/queue").response
end

#reblog_post(id, reblog_key, options = {}) ⇒ Object

Reblog a Post

Parameters:

  • id (Integer)

    The ID of the reblogged post on tumblelog

  • reblog_key (Integer)

    The reblog key for the reblogged post – get the reblog key with a /posts request

  • options (Hash) (defaults to: {})

    A customizable set of options

Options Hash (options):

  • :comment (String)

    A comment added to the reblogged post

See Also:



181
182
183
# File 'lib/tumble/blog.rb', line 181

def reblog_post(id, reblog_key, options={})
  @connection.post("/blog/#{name}/post/reblog", options.merge('id' => id, 'reblog_key' => reblog_key)).response
end

#submissionsObject

Retreive Submission Posts



80
81
82
# File 'lib/tumble/blog.rb', line 80

def submissions
  @connection.get("/blog/#{name}/posts/submission").response
end