Module: Sinatra::Numeric
- Defined in:
- lib/sinatra/support/numeric.rb
Overview
Provides numeric helpers.
require 'sinatra/support/numeric'
class Main < Sinatra::Base
register Sinatra::Numeric
end
Helpers
This plugin provides the following helpers:
currency - Formats a string as a currency.
<%= currency(100) %>
<!-- $100 -->
percentage - Formats a number as a percentage.
<%= percentage(100) %>
<!-- 100.00% -->
Settings
You may change the settings like so:
Main.configure do |m|
m.set :default_currency_unit, '$'
m.set :default_currency_precision, 2
m.set :default_currency_separator, ','
end
Defined Under Namespace
Modules: Helpers