Module: MediServ::API::Format

Included in:
Node, Struct
Defined in:
lib/mediserv/api/format.rb

Instance Method Summary collapse

Instance Method Details

#fmt_amount(n) ⇒ Object



11
12
13
# File 'lib/mediserv/api/format.rb', line 11

def fmt_amount(n)
  n ? sprintf('%0.2f', n) : '0.00'
end

#fmt_date(d) ⇒ Object



3
4
5
# File 'lib/mediserv/api/format.rb', line 3

def fmt_date(d)
  d ? d.strftime('%d.%m.%Y') : ''
end

#fmt_string(s, max: nil) ⇒ Object



15
16
17
# File 'lib/mediserv/api/format.rb', line 15

def fmt_string(s, max: nil)
  max ? s[0..max] : s
end

#fmt_time(t) ⇒ Object



7
8
9
# File 'lib/mediserv/api/format.rb', line 7

def fmt_time(t)
  t ? t.strftime('%H:%M') : ''
end