lib/tabulatr/tabulatr/formattr.rb in tabulatr-0.3.0 vs lib/tabulatr/tabulatr/formattr.rb in tabulatr-0.4.0

- old
+ new

@@ -21,10 +21,11 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #++ module Tabulatr::Formattr ALLOWED_METHODS = [:euro, :dollar, :percent, :lamp] + #include ActionView::TagHelpers def self.format(nam, val) nam = nam.to_sym if ALLOWED_METHODS.member?(nam) self.send nam, val @@ -43,9 +44,12 @@ def self.percent(x) ("%.2f&thinspace;%%" % 100.0*x).gsub(".", ",") end - def self.lamp(x) - + def self.lamp(x, mapping) + s = mapping[x].to_s + return "?" unless %w{g y r n}.member?(s) + image_tag("tabulatr/#{s}state.gif").html_safe end + end \ No newline at end of file