Module: EasyAsPie::ViewHelper

Defined in:
lib/easy_as_pie/view_helper.rb

Instance Method Summary collapse

Instance Method Details

#easy_as_pie(percent, *args) ⇒ Object

<div class=“chart” data-percent=“73”>73%</div>

Raises:

  • (ArgumentError)


5
6
7
8
9
10
11
12
13
14
15
# File 'lib/easy_as_pie/view_helper.rb', line 5

def easy_as_pie percent, *args
  raise ArgumentError, "Must take a percent argument" unless percent
  pie_options = {:"data-percent" => percent, :class => 'chart'}
  
  options = args.extract_options!
  pie_options.merge!(options || {})

  label = args.first || "#{percent}%"

   :div, label, pie_options
end