Module: Tumblr::Post
- Included in:
- Client
- Defined in:
- lib/tumblr/post.rb
Constant Summary collapse
- STANDARD_POST_OPTIONS =
[:state, :tags, :tweet, :date, :markdown, :slug, :format]
- DATA_POST_TYPES =
[:audio, :video, :photo]
- VALID_POST_TYPES =
DATA_POST_TYPES + [:quote, :text, :link, :chat]
Instance Method Summary collapse
- #audio(blog_name, options = {}) ⇒ Object
- #chat(blog_name, options = {}) ⇒ Object
- #create_post(type, blog_name, options = {}) ⇒ Object
- #delete(blog_name, id) ⇒ Object
- #edit(blog_name, options = {}) ⇒ Object
- #link(blog_name, options = {}) ⇒ Object
- #photo(blog_name, options = {}) ⇒ Object
- #quote(blog_name, options = {}) ⇒ Object
- #reblog(blog_name, options = {}) ⇒ Object
- #text(blog_name, options = {}) ⇒ Object
- #video(blog_name, options = {}) ⇒ Object
Instance Method Details
#audio(blog_name, options = {}) ⇒ Object
68 69 70 71 72 73 74 75 76 |
# File 'lib/tumblr/post.rb', line 68 def audio(blog_name, = {}) valid_opts = STANDARD_POST_OPTIONS + [:data, :caption, :external_url] (valid_opts, ) validate_no_collision , [:data, :external_url] [:type] = 'audio' extract_data!() post(post_path(blog_name), ) end |
#chat(blog_name, options = {}) ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/tumblr/post.rb', line 60 def chat(blog_name, = {}) valid_opts = STANDARD_POST_OPTIONS + [:title, :conversation] (valid_opts, ) [:type] = 'chat' post(post_path(blog_name), ) end |
#create_post(type, blog_name, options = {}) ⇒ Object
88 89 90 91 92 93 94 |
# File 'lib/tumblr/post.rb', line 88 def create_post(type, blog_name, = {}) if VALID_POST_TYPES.include?(type) send(type, blog_name, ) else raise ArgumentError.new "\"#{type}\" is not a valid post type" end end |
#delete(blog_name, id) ⇒ Object
21 22 23 |
# File 'lib/tumblr/post.rb', line 21 def delete(blog_name, id) post(blog_path(blog_name, 'post/delete'), :id => id) end |
#edit(blog_name, options = {}) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/tumblr/post.rb', line 10 def edit(blog_name, = {}) convert_source_array :source, extract_data!() if DATA_POST_TYPES.include?([:type]) post(blog_path(blog_name, 'post/edit'), ) end |
#link(blog_name, options = {}) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/tumblr/post.rb', line 52 def link(blog_name, = {}) valid_opts = STANDARD_POST_OPTIONS + [:title, :url, :description] (valid_opts, ) [:type] = 'link' post(post_path(blog_name), ) end |
#photo(blog_name, options = {}) ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/tumblr/post.rb', line 25 def photo(blog_name, = {}) valid_opts = STANDARD_POST_OPTIONS + [:caption, :link, :data, :source, :photoset_layout] (valid_opts, ) validate_no_collision , [:data, :source] convert_source_array :source, [:type] = 'photo' extract_data!() post(post_path(blog_name), ) end |
#quote(blog_name, options = {}) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/tumblr/post.rb', line 36 def quote(blog_name, = {}) valid_opts = STANDARD_POST_OPTIONS + [:quote, :source] (valid_opts, ) [:type] = 'quote' post(post_path(blog_name), ) end |
#reblog(blog_name, options = {}) ⇒ Object
17 18 19 |
# File 'lib/tumblr/post.rb', line 17 def reblog(blog_name, = {}) post(blog_path(blog_name, 'post/reblog'), ) end |
#text(blog_name, options = {}) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/tumblr/post.rb', line 44 def text(blog_name, = {}) valid_opts = STANDARD_POST_OPTIONS + [:title, :body] (valid_opts, ) [:type] = 'text' post(post_path(blog_name), ) end |
#video(blog_name, options = {}) ⇒ Object
78 79 80 81 82 83 84 85 86 |
# File 'lib/tumblr/post.rb', line 78 def video(blog_name, = {}) valid_opts = STANDARD_POST_OPTIONS + [:data, :embed, :caption] (valid_opts, ) validate_no_collision , [:data, :embed] [:type] = 'video' extract_data!() post(post_path(blog_name), ) end |