With the help of this gem you can manipulate with polls of strawpoll.me service. You can get, create polls and also vote.
Add this line to your application's Gemfile:
gem 'strawpoll'
And then execute:
$ bundle
Or install it yourself as:
$ gem install strawpoll
You can create poll this way:
Strawpoll::Poll.create(title: 'Do you like this gem?', options: ['Yes', 'No'])
=> #<Strawpoll::Poll:0x007fb8e4162f70 @id=3057139, @title="Do you like this gem?", @options=["Yes", "No"], @votes=[], @multi=false, @permissive=false>
and this way:
poll = Strawpoll::Poll.new(title: 'Do you like this gem?', options: ["Yes", "No"])
poll.create
=> #<Strawpoll::Poll:0x007fb8e40a2dd8 @id=3057160, @title="Do you like this gem?", @options=["Yes", "No"], @votes=[], @multi=false, @permissive=false>
Also to reload poll(to update votes):
poll.reload
=> #<Strawpoll::Poll:0x007fb8e40a2dd8 @id=3057160, @title="Do you like this gem?", @options=["Yes", "No"], @votes=[0, 0], @multi="false", @permissive="false">
You can get existing poll:
Strawpoll::Poll.get(3057160)
=> #<Strawpoll::Poll:0x007fb8e70519d0 @id=3057160, @title="Do you like this gem?", @options=["Yes", "No"], @votes=[0, 0], @multi="false", @permissive="false">
You can vote and get votes count:
poll.vote('Yes')
=> #<Strawpoll::Poll:0x007fb8e40a2dd8 @id=3057160, @title="Do you like this gem?", @options=["Yes", "No"], @votes=[1, 0], @multi="false", @permissive="false">
poll.votes_count
=> {"Yes"=>1, "No"=>0}
poll.votes_count("Yes")
=> 1
- Fork it ( https://github.com/enotpoloskun/strawpoll/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request