module Rubybear::Mixins::ActsAsVoter

Public Instance Methods

vote(weight, *args) click to toggle source

Create a vote operation.

Examples:

bears = Rubybear::Chain.new(chain: :bears, account_name: 'your account name', wif: 'your wif')
bears.vote(10000, 'author', 'permlink')
bears.broadcast!

… or …

bears = Rubybear::Chain.new(chain: :bears, account_name: 'your account name', wif: 'your wif')
bears.vote(10000, '@author/permlink')
bears.broadcast!

@param weight [Integer] value between -10000 and 10000. @param args [author, permlink || slug] pass either `author` and `permlink` or string containing both like `@author/permlink`.

# File lib/rubybear/mixins/acts_as_voter.rb, line 20
def vote(weight, *args)
  author, permlink = normalize_author_permlink(args)
  
  @operations << {
    type: :vote,
    voter: account_name,
    author: author,
    permlink: permlink,
    weight: weight
  }
  
  self
end
vote!(weight, *args) click to toggle source

Create a vote operation and broadcasts it right away.

Examples:

bears = Rubybear::Chain.new(chain: :bears, account_name: 'your account name', wif: 'your wif')
bears.vote!(10000, 'author', 'permlink')

… or …

bears = Rubybear::Chain.new(chain: :bears, account_name: 'your account name', wif: 'your wif')
bears.vote!(10000, '@author/permlink')

@see vote

# File lib/rubybear/mixins/acts_as_voter.rb, line 47
def vote!(weight, *args); vote(weight, *args).broadcast!(true); end