Module: Richard::QueuedUserFormatter
- Extended by:
- QueuedUserFormatter
- Included in:
- QueuedUserFormatter
- Defined in:
- lib/richard/queued_user_formatter.rb
Instance Method Summary collapse
- #format_duration(duration) ⇒ Object
- #row_header ⇒ Object
- #table_format(users) ⇒ Object
- #user_to_row(user) ⇒ Object
Instance Method Details
#format_duration(duration) ⇒ Object
35 36 37 |
# File 'lib/richard/queued_user_formatter.rb', line 35 def format_duration(duration) (duration) ? Time.at(duration).utc.strftime("%Hh %Mm %Ss") : '--' end |
#row_header ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/richard/queued_user_formatter.rb', line 17 def row_header [ "User Id", "User", "Status", "Blocking Duration" ] end |
#table_format(users) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/richard/queued_user_formatter.rb', line 7 def table_format(users) # return Terminal::Table.new(rows: rows) Terminal::Table.new do |table| table << row_header table.add_separator users.each { |user| table << user_to_row(user) } end end |
#user_to_row(user) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/richard/queued_user_formatter.rb', line 26 def user_to_row(user) return [ user.user_id, user.email, user.status, format_duration(user.blocking_duration) ] end |