Module: GemsBond::Helpers::FormattingHelper
- Included in:
- Printers::HTML, Printers::Stdout
- Defined in:
- lib/gems_bond/helpers/formatting_helper.rb
Overview
Formatting helper
Constant Summary collapse
- MISSING =
"-"
Class Method Summary collapse
-
.human_date(date) ⇒ String
Returns a date with a readable format.
-
.human_number(number) ⇒ String
Returns a number with a readable format.
-
.human_score(score) ⇒ String
Returns score out of 100.
Class Method Details
.human_date(date) ⇒ String
Returns a date with a readable format
17 18 19 20 21 |
# File 'lib/gems_bond/helpers/formatting_helper.rb', line 17 def human_date(date) return MISSING if date.nil? date.strftime("%F") end |
.human_number(number) ⇒ String
Returns a number with a readable format
29 30 31 32 33 |
# File 'lib/gems_bond/helpers/formatting_helper.rb', line 29 def human_number(number) return MISSING if number.nil? number.to_s.gsub(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1 ") end |
.human_score(score) ⇒ String
Returns score out of 100
41 42 43 44 45 |
# File 'lib/gems_bond/helpers/formatting_helper.rb', line 41 def human_score(score) return MISSING if score.nil? (score * 100).round end |