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 (:comment) (defaults to: {})
    String

    HTML or Text Comment

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

    Limit number of posts selected

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

    Modify only posts containing key_text 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



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/draftking/drafts.rb', line 33

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_space)
    next false unless post.has_key_text?(@key_text)
    post.replace_comment_with(@comment)
    post.change_state(@state)
    post.generate_tags(keep_tags: @keep_tags,
                       add_tags:  @tags,
                       exclude:   @comment,
                       credit:    @credit) if @auto_tag
  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 |post, _|
    post.changed = true
  end
end

#strip_tags(options = {}) ⇒ Object



16
17
18
19
20
21
# File 'lib/draftking/drafts.rb', line 16

def strip_tags(options = {})
  options[:message] = 'Stripping previous comments: '
  post_operation(options) do |post, _|
    post.clear_tags
  end
end