Class: SimpleTumblr
- Inherits:
-
Object
- Object
- SimpleTumblr
- Includes:
- Enumerable, HTTParty
- Defined in:
- lib/simple_tumblr.rb,
lib/simple_tumblr/version.rb
Defined Under Namespace
Classes: Post
Constant Summary collapse
- VERSION =
'0.1.0'
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#initialize(options = {}) ⇒ SimpleTumblr
constructor
A new instance of SimpleTumblr.
- #posts(options = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ SimpleTumblr
Returns a new instance of SimpleTumblr.
10 11 12 |
# File 'lib/simple_tumblr.rb', line 10 def initialize( = {}) self. = end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
7 8 9 |
# File 'lib/simple_tumblr.rb', line 7 def @options end |
Class Method Details
.method_missing(method, *args, &block) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/simple_tumblr.rb', line 43 def method_missing(method, *args, &block) instance = new if instance.respond_to?(method) instance. = args. if instance.method(method).arity == 1 instance.send(method, args) else instance.send(method) end else super end end |
Instance Method Details
#each(&block) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/simple_tumblr.rb', line 35 def each(&block) response = self.class.get("/v2/blog/#{self..delete(:hostname)}/posts", query: @options) raise response['meta']['msg'] unless response.success? response['response']['posts'].map { |data| Post.new(data) }.each(&block) end |
#posts(options = {}) ⇒ Object
14 15 16 17 |
# File 'lib/simple_tumblr.rb', line 14 def posts( = {}) self. = self..merge() self end |