Module: BravoPresenter::Filters
- Included in:
- Base
- Defined in:
- lib/bravo_presenter/filters.rb
Instance Method Summary collapse
-
#collection(value) ⇒ Object
nodoc.
-
#currency(value, options = {}) ⇒ Object
nodoc.
-
#datetime(value, format = :short) ⇒ Object
nodoc.
-
#presenter(value) ⇒ Object
nodoc.
-
#text(value, options = {}) ⇒ Object
nodoc.
Instance Method Details
#collection(value) ⇒ Object
nodoc
5 6 7 |
# File 'lib/bravo_presenter/filters.rb', line 5 def collection(value) template.present_collection(value) end |
#currency(value, options = {}) ⇒ Object
nodoc
11 12 13 14 |
# File 'lib/bravo_presenter/filters.rb', line 11 def currency(value, ={}) [:unit] ||= object.country.currency.symbol rescue '$' template.number_to_currency(value, ) end |
#datetime(value, format = :short) ⇒ Object
nodoc
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/bravo_presenter/filters.rb', line 18 def datetime(value, format=:short) format = case format when :mmm_yyyy then "%b %y" when :dd_mmm then "%d %b" when :date_at_time then "%d %b at %l:%M%P" when :time_on_date then "%l:%M%P on %d %b" when :datetime then "%d %b %l:%M%P" else format end return value.to_s(format) unless format.is_a?(String) value.strftime format end |
#presenter(value) ⇒ Object
nodoc
33 34 35 36 |
# File 'lib/bravo_presenter/filters.rb', line 33 def presenter(value) return nil if value.nil? template.present_object(value) end |
#text(value, options = {}) ⇒ Object
nodoc
40 41 42 43 44 45 |
# File 'lib/bravo_presenter/filters.rb', line 40 def text(value, ={}) if length = .delete(:truncate) value = template.truncate(value, :length => length) end value end |