Module: Radiator::Mixins::ActsAsPoster

Included in:
Chain
Defined in:
lib/radiator/mixins/acts_as_poster.rb

Instance Method Summary collapse

Instance Method Details

#delete_comment(permlink) ⇒ Object

Create a delete_comment operation.

Examples:

steem = Radiator::Chain.new(chain: :steem, account_name: 'your account name', wif: 'your wif')
steem.delete_comment('permlink')
steem.broadcast!

Parameters:

  • permlink


103
104
105
106
107
108
109
110
111
# File 'lib/radiator/mixins/acts_as_poster.rb', line 103

def delete_comment(permlink)
  @operations << {
    type: :delete_comment,
    author: ,
    permlink: permlink
  }
  
  self
end

#delete_comment!(permlink) ⇒ Object

Create a delete_comment operation and broadcasts it right away.

Examples:

steem = Radiator::Chain.new(chain: :steem, account_name: 'your account name', wif: 'your wif')
steem.delete_comment!('permlink')

See Also:



121
# File 'lib/radiator/mixins/acts_as_poster.rb', line 121

def delete_comment!(permlink); delete_comment(permlink).broadcast!(true); end

#post(options = {}) ⇒ Object

Creates a post operation.

steem = Radiator::Chain.new(chain: :steem, account_name: 'your account name', wif: 'your wif')
options = {
  title: 'This is my fancy post title.',
  body: 'This is my fancy post body.',
  tags: %w(thess are my fancy tags)
}
steem.post(options)
steem.broadcast!

Parameters:

  • options (::Hash) (defaults to: {})

    options

Options Hash (options):

  • :title (String)

    Title of the post.

  • :body (String)

    Body of the post.

  • :tags (::Array<String>)

    Tags of the post.

  • :permlink (String) — default: automatic

    Permlink of the post, defaults to formatted title.

  • :parent_permlink (String) — default: automatic

    Parent permlink of the post, defaults to first tag.

  • :parent_author (String) — default: optional

    Parent author of the post (only used if reply).

  • :max_accepted_payout (String) — default: 1000000.000 SBD

    Maximum accepted payout, set to ‘0.000 SBD’ to deline payout

  • :percent_hbd (Integer) — default: 5000

    Percent HBD is used to set 50/50 or 100% HIVE Power

  • :allow_votes (Integer) — default: true

    Allow votes for this post.

  • :allow_curation_rewards (Integer) — default: true

    Allow curation rewards for this post.

Raises:



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/radiator/mixins/acts_as_poster.rb', line 26

def post(options = {})
  tags = [options[:tags] || []].flatten
  title = options[:title].to_s
  permlink = options[:permlink] || title.downcase.gsub(/[^a-z0-9\-]+/, '-')
  parent_permlink = options[:parent_permlink] || tags[0]
  
  raise ChainError, 'At least one tag is required or set the parent_permlink directy.' if parent_permlink.nil?
  
  body = options[:body]
  parent_author = options[:parent_author] || ''
  max_accepted_payout = options[:max_accepted_payout] || default_max_acepted_payout
  percent_hbd = options[:percent_hbd]
  allow_votes = options[:allow_votes] || true
  allow_curation_rewards = options[:allow_curation_rewards] || true
  self_vote = options[:self_vote]
  
  tags.insert(0, parent_permlink)
  tags = tags.compact.uniq
  
   = {
    app: Radiator::AGENT_ID
  }
  [:tags] = tags if tags.any?
  
  @operations << {
    type: :comment,
    parent_permlink: parent_permlink,
    author: ,
    permlink: permlink,
    title: title,
    body: body,
    json_metadata: .to_json,
    parent_author: parent_author
  }
  
  if (!!max_accepted_payout &&
      max_accepted_payout != default_max_acepted_payout
    ) || !!percent_hbd || !allow_votes || !allow_curation_rewards
    @operations << {
      type: :comment_options,
      author: ,
      permlink: permlink,
      max_accepted_payout: max_accepted_payout,
      percent_hbd: percent_hbd,
      allow_votes: allow_votes,
      allow_curation_rewards: allow_curation_rewards,
      extensions: []
    }
  end
  
  vote(self_vote, , permlink) if !!self_vote
  
  self
end

#post!(options = {}) ⇒ Object

Create a vote operation and broadcasts it right away.

steem = Radiator::Chain.new(chain: :steem, account_name: 'your account name', wif: 'your wif')
options = {
  title: 'This is my fancy post title.',
  body: 'This is my fancy post body.',
  tags: %w(thess are my fancy tags)
}
steem.post!(options)

See Also:



92
# File 'lib/radiator/mixins/acts_as_poster.rb', line 92

def post!(options = {}); post(options).broadcast!(true); end