Class: TallyGem::Printers::Common

Inherits:
Object
  • Object
show all
Defined in:
lib/tallygem/printers/common.rb

Class Method Summary collapse

Class Method Details

.render_vote(vote, depth = 0) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/tallygem/printers/common.rb', line 4

def render_vote(vote, depth = 0)
  depth = vote[:depth] if vote.key? :depth

  rv = '-' * depth
  rv << '[X]'
  rv << "[#{vote[:task]}]" if vote.key?(:task)
  rv << vote[:vote_text]
  vote[:subvotes].each { |sv| rv << "\n" + render_vote(sv, depth + 1) } if vote.key? :subvotes
  rv
end