Class: DK::Client
- Inherits:
-
Object
- Object
- DK::Client
- Defined in:
- lib/draftking/client.rb
Overview
Tumblr Client
Instance Attribute Summary collapse
-
#auto_tag ⇒ Object
Returns the value of attribute auto_tag.
-
#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.
-
#state ⇒ Object
Returns the value of attribute state.
-
#tags ⇒ Object
Returns the value of attribute tags.
-
#test_data ⇒ Object
Returns the value of attribute test_data.
-
#type ⇒ Object
Returns the value of attribute type.
-
#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.
- #connected? ⇒ Boolean
-
#initialize(options = {}) ⇒ Client
constructor
Initialize instance of DraftKing for the specified blog.
-
#process_options(options) ⇒ Object
Read Config.
-
#process_source(src) ⇒ Object
Process options.
Methods included from Posts
#all_posts, #auto_poster, #calculate_result, #call_source, #comment_posts, #dashboard?, #generate_worker, #get_posts, #index_within_limit?, #likes?, #limited_posts, #post_operation, #posts_to_queue, #setup_done, #setup_operation, #setup_undone, #show_progress, #shufflex, #some_posts, #some_test_data, #source_string, #tag_posts, #tumblr_url
Methods included from TQueue
Methods included from TDrafts
#drafts_to_queue, #strip_old_comments, #strip_tags
Constructor Details
Instance Attribute Details
#auto_tag ⇒ Object
Returns the value of attribute auto_tag.
16 17 18 |
# File 'lib/draftking/client.rb', line 16 def auto_tag @auto_tag end |
#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 |
#state ⇒ Object
Returns the value of attribute state.
16 17 18 |
# File 'lib/draftking/client.rb', line 16 def state @state end |
#tags ⇒ Object
Returns the value of attribute tags.
17 18 19 |
# File 'lib/draftking/client.rb', line 17 def @tags 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 |
#type ⇒ Object
Returns the value of attribute type.
17 18 19 |
# File 'lib/draftking/client.rb', line 17 def type @type 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
65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/draftking/client.rb', line 65 def act_on_blog(name: nil) return unless connected? @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 = 300 - @q_size end end |
#configure_tumblr_client(options) ⇒ Object
Configure tumblr_client gem
57 58 59 60 61 |
# File 'lib/draftking/client.rb', line 57 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 |
#connected? ⇒ Boolean
79 80 81 |
# File 'lib/draftking/client.rb', line 79 def connected? @client && @client.info['status'] != 401 end |
#process_options(options) ⇒ Object
Read Config
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/draftking/client.rb', line 30 def () @blog_name = [:blog_name] || @blog_name @credit = [:credit] || @credit @key_text = [:key_text] || @key_text @keep_tree = [:keep_tree] || @keep_tree @keep_tags = [:keep_tags] || @keep_tags @message = [:message] || @message @mute = [:mute] || @mute @shuffle = [:shuffle] || @shuffle @simulate = [:simulate] || @simulate @state = [:state] || @state @test_data = [:test_data] || @test_data @tags = [:add_tags] || @tags @comment = [:comment] || @comment.to_s @auto_tag = [:tags].nil? ? true : [:tags] @source = process_source([:source]) @before_id = [:before_id] || 0 @offset = [:offset] || 0 @greedy = [:greedy] || @greedy @limit = [:limit] @type = [:type] @blog_url = tumblr_url(@blog_name) end |
#process_source(src) ⇒ Object
Process options
84 85 86 87 88 89 |
# File 'lib/draftking/client.rb', line 84 def process_source(src) return :draft unless src return src if src.is_a? Symbol return :dashboard if src.include?('dash') return :queue if src.include?('queue') end |