Module: DK::TDrafts

Included in:
Client
Defined in:
lib/draftking/drafts.rb

Overview

Draft methods

Instance Method Summary collapse

Instance Method Details

#drafts_to_queue(options = {}) ⇒ int

Move Drafts to Queue

Parameters:

  • options (:credit) (defaults to: {})
    Bool

    Give DK credit?

  • options (:limit) (defaults to: {})
    int

    Limit number of posts selected

  • options (:filter) (defaults to: {})
    string

    Modify only posts containing filter string

  • options (:mute) (defaults to: {})
    String

    Suppress progress indicator

  • options (:keep_tags) (defaults to: {})
    bool

    Preserve existing post tags

  • options (:keep_tree) (defaults to: {})
    bool

    Preserve existing post comments

  • options (:simulate) (defaults to: {})
    bool

    Simulation?

Returns:

  • (int)

    Number of modified posts



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/draftking/drafts.rb', line 25

def drafts_to_queue(options = {})
  options[:message] = 'Moving Drafts -> Queue: '
  options[:shuffle] = true
  options[:state]   = DK::QUEUE
  post_operation(options) do |post, index|
    next false unless index_within_limit?(index, @q_size)
    next false unless post.passes_filter?(filter: @filter)
    changed = post.replace_comment(comment: @comment)
    changed = post.change_state(state: @state) || changed
    changed = post.generate_tags(keep_tags: @keep_tags,
                                 add_tags:  @tags,
                                 exclude:   @comment,
                                 credit:    @credit) || changed
    changed
  end
end

#strip_old_comments(options = {}) ⇒ int

Remove comment tree

Parameters:

  • options (:limit) (defaults to: {})
    int

    Limit number of posts selected

  • options (:mute) (defaults to: {})
    bool

    Suppress progress indicator?

  • options (:simulate) (defaults to: {})
    bool

    Simulation?

Returns:

  • (int)

    Number of modified posts



9
10
11
12
13
14
# File 'lib/draftking/drafts.rb', line 9

def strip_old_comments(options = {})
  options[:message] = 'Stripping previous comments: '
  post_operation(options) do |_, _index|
    true
  end
end