Class: DK::Client
- Inherits:
-
Object
- Object
- DK::Client
- Defined in:
- lib/draftking/client.rb
Overview
tumblr Client
Instance Attribute Summary collapse
-
#before_id ⇒ Object
Returns the value of attribute before_id.
-
#blog ⇒ Object
Returns the value of attribute blog.
-
#blog_name ⇒ Object
Options.
-
#blog_url ⇒ Object
Returns the value of attribute blog_url.
-
#client ⇒ Object
Returns the value of attribute client.
-
#comment ⇒ Object
Options.
-
#credit ⇒ Object
Returns the value of attribute credit.
-
#d_size ⇒ Object
Returns the value of attribute d_size.
-
#keep_tags ⇒ Object
Returns the value of attribute keep_tags.
-
#keep_tree ⇒ Object
Returns the value of attribute keep_tree.
-
#limit ⇒ Object
Options.
-
#message ⇒ Object
Returns the value of attribute message.
-
#mute ⇒ Object
Returns the value of attribute mute.
-
#offset ⇒ Object
Options.
-
#q_size ⇒ Object
Returns the value of attribute q_size.
-
#q_space ⇒ Object
Returns the value of attribute q_space.
-
#shuffle ⇒ Object
Returns the value of attribute shuffle.
-
#simulate ⇒ Object
Returns the value of attribute simulate.
-
#source ⇒ Object
Returns the value of attribute source.
-
#test_data ⇒ Object
Returns the value of attribute test_data.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
-
#act_on_blog(name: nil) ⇒ Object
Collect/Refresh Account Info.
-
#configure_tumblr_client(options) ⇒ Object
Configure tumblr_client gem.
-
#initialize(options = {}) ⇒ Client
constructor
Initialize instance of DraftKing for the specified blog.
-
#process_options(options) ⇒ Object
Read Config.
Methods included from Posts
#all_posts, #calculate_result, #comment_posts, #get_posts, #index_within_limit?, #limited_posts, #post_operation, #posts_to_queue, #setup_done, #setup_operation, #setup_undone, #show_progress, #some_posts, #source_string, #tag_posts, #tumblr_url
Methods included from TQueue
Methods included from TDrafts
#drafts_to_queue, #strip_old_comments
Constructor Details
Instance Attribute Details
#before_id ⇒ Object
Returns the value of attribute before_id.
15 16 17 |
# File 'lib/draftking/client.rb', line 15 def before_id @before_id end |
#blog ⇒ Object
Returns the value of attribute blog.
9 10 11 |
# File 'lib/draftking/client.rb', line 9 def blog @blog end |
#blog_name ⇒ Object
Options
13 14 15 |
# File 'lib/draftking/client.rb', line 13 def blog_name @blog_name end |
#blog_url ⇒ Object
Returns the value of attribute blog_url.
9 10 11 |
# File 'lib/draftking/client.rb', line 9 def blog_url @blog_url end |
#client ⇒ Object
Returns the value of attribute client.
8 9 10 |
# File 'lib/draftking/client.rb', line 8 def client @client end |
#comment ⇒ Object
Options
13 14 15 |
# File 'lib/draftking/client.rb', line 13 def comment @comment end |
#credit ⇒ Object
Returns the value of attribute credit.
15 16 17 |
# File 'lib/draftking/client.rb', line 15 def credit @credit end |
#d_size ⇒ Object
Returns the value of attribute d_size.
10 11 12 |
# File 'lib/draftking/client.rb', line 10 def d_size @d_size end |
#keep_tags ⇒ Object
Returns the value of attribute keep_tags.
15 16 17 |
# File 'lib/draftking/client.rb', line 15 def @keep_tags end |
#keep_tree ⇒ Object
Returns the value of attribute keep_tree.
14 15 16 |
# File 'lib/draftking/client.rb', line 14 def keep_tree @keep_tree end |
#limit ⇒ Object
Options
13 14 15 |
# File 'lib/draftking/client.rb', line 13 def limit @limit end |
#message ⇒ Object
Returns the value of attribute message.
16 17 18 |
# File 'lib/draftking/client.rb', line 16 def @message end |
#mute ⇒ Object
Returns the value of attribute mute.
14 15 16 |
# File 'lib/draftking/client.rb', line 14 def mute @mute end |
#offset ⇒ Object
Options
13 14 15 |
# File 'lib/draftking/client.rb', line 13 def offset @offset end |
#q_size ⇒ Object
Returns the value of attribute q_size.
10 11 12 |
# File 'lib/draftking/client.rb', line 10 def q_size @q_size end |
#q_space ⇒ Object
Returns the value of attribute q_space.
10 11 12 |
# File 'lib/draftking/client.rb', line 10 def q_space @q_space end |
#shuffle ⇒ Object
Returns the value of attribute shuffle.
14 15 16 |
# File 'lib/draftking/client.rb', line 14 def shuffle @shuffle end |
#simulate ⇒ Object
Returns the value of attribute simulate.
15 16 17 |
# File 'lib/draftking/client.rb', line 15 def simulate @simulate end |
#source ⇒ Object
Returns the value of attribute source.
16 17 18 |
# File 'lib/draftking/client.rb', line 16 def source @source end |
#test_data ⇒ Object
Returns the value of attribute test_data.
14 15 16 |
# File 'lib/draftking/client.rb', line 14 def test_data @test_data end |
#user ⇒ Object
Returns the value of attribute user.
8 9 10 |
# File 'lib/draftking/client.rb', line 8 def user @user end |
Instance Method Details
#act_on_blog(name: nil) ⇒ Object
Collect/Refresh Account Info
60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/draftking/client.rb', line 60 def act_on_blog(name: nil) @user = JSON.parse(@client.info['user'].to_json, object_class: OpenStruct) @blog_name = name ? name.gsub('.tumblr.com', '') : @user.blogs.first.name @blog_url = tumblr_url(@blog_name) @user.blogs.each do |blog| next unless blog.name == @blog_name @blog = blog @q_size = blog.queue @d_size = blog.drafts @q_space = 301 - @q_size end end |
#configure_tumblr_client(options) ⇒ Object
Configure tumblr_client gem
52 53 54 55 56 |
# File 'lib/draftking/client.rb', line 52 def configure_tumblr_client() keys = DK::Config.validate_keys([:keys]) return DK::Config.configure_tumblr_gem(keys: keys) unless keys.nil? DK::Config.configure_tumblr_gem(file: [:config_file]) end |
#process_options(options) ⇒ Object
Read Config
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/draftking/client.rb', line 29 def () @blog_name = [:blog_name] || @blog_name @before_id = [:before_id] || 0 @comment = [:comment] || @comment.to_s @credit = [:credit] || @credit @filter = [:filter] || @filter @keep_tree = [:keep_tree] || @keep_tree @keep_tags = [:keep_tags] || @keep_tags @limit = [:limit] @message = [:message] || @message @mute = [:mute] || @mute @offset = [:offset] || 0 @source = [:source] || :draft @shuffle = [:shuffle] || @shuffle @simulate = [:simulate] || @simulate @state = [:state] || @state @tags = [:add_tags] || @tags @test_data = [:test_data] || @test_data end |