Module: JobHelper
- Defined in:
- app/helpers/job_helper.rb
Instance Method Summary collapse
- #human_size_if_nz(val) ⇒ Object
- #level_name(c) ⇒ Object
- #secs_to_hms(sec) ⇒ Object
- #status_name(c) ⇒ Object
- #status_style(s) ⇒ Object
- #type_name(c) ⇒ Object
- #when_full(s) ⇒ Object
- #when_tiny(s) ⇒ Object
Instance Method Details
#human_size_if_nz(val) ⇒ Object
11 12 13 |
# File 'app/helpers/job_helper.rb', line 11 def human_size_if_nz(val) val <= 0 ? '-' : number_to_human_size(val) end |
#level_name(c) ⇒ Object
29 30 31 32 33 34 |
# File 'app/helpers/job_helper.rb', line 29 def level_name(c) name = { 'F' => 'Full', 'I' => 'Incr', 'D' => 'Diff', 'O' => 'Catalog', } name[c] || c end |
#secs_to_hms(sec) ⇒ Object
15 16 17 18 19 20 |
# File 'app/helpers/job_helper.rb', line 15 def secs_to_hms(sec) return '-' if sec <= 0 s = sec.divmod(60) m = s[0].divmod(60) sprintf '%d:%02d:%02d', m[0], m[1], s[1] end |
#status_name(c) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/helpers/job_helper.rb', line 36 def status_name(c) name = { 'A' => 'Cancel', 'B' => 'Blocked', 'C' => 'Created', 'D' => 'Diffs', 'R' => 'Running', 'T' => 'Okay', 'E' => 'Error', 'e' => 'Non-fatal', 'f' => 'Fatal', 'F' => 'FD Wait', 'M' => 'Mount Wait', 'S' => 'SD Wait', 'c' => 'FR Wait', 'd' => 'Jmax Wait', 'j' => 'JR Wait', 'm' => 'Media Wait', 'p' => 'Prio Wait', 's' => 'SR Wait', 't' => 'Start Wait', } name[c] || c end |
#status_style(s) ⇒ Object
49 50 51 52 53 54 |
# File 'app/helpers/job_helper.rb', line 49 def status_style(s) stat = { 'T' => 'normal', 'R' => 'okay', 'C' => 'pending', 'A' => 'cancel', 'E' => 'error', 'f' => 'error', } content_tag('td', status_name(s), 'class' => stat[s] || 'oops') end |
#type_name(c) ⇒ Object
22 23 24 25 26 27 |
# File 'app/helpers/job_helper.rb', line 22 def type_name(c) name = { 'B' => 'Backup', 'D' => 'Admin', 'V' => 'Verify', 'R' => 'Restore', } name[c] || c end |
#when_full(s) ⇒ Object
3 4 5 |
# File 'app/helpers/job_helper.rb', line 3 def when_full(s) !s ? '-' : s.strftime('%a %b %d %H:%M') end |
#when_tiny(s) ⇒ Object
7 8 9 |
# File 'app/helpers/job_helper.rb', line 7 def when_tiny(s) !s ? '-' : s.strftime('%H:%M %a') end |