class Zend::Command::Ticket::Show

Attributes

ticket[R]

Public Class Methods

new(id) click to toggle source
# File lib/zend/command/ticket/show.rb, line 6
def initialize(id)
  @ticket = remote_ticket(id)

  puts(output)
end

Public Instance Methods

output() click to toggle source
# File lib/zend/command/ticket/show.rb, line 12
def output
  table.to_s + ticket.description
end
table() click to toggle source
# File lib/zend/command/ticket/show.rb, line 16
def table
  Terminal::Table.new(
    style: {
      width: terminal_width,
      padding_left: 3
    },
    rows: tabular_data
  )
end
tabular_data() click to toggle source
# File lib/zend/command/ticket/show.rb, line 26
def tabular_data
  rows = Array.new
  rows << [value: col_subject, colspan: 3]
  rows << :separator
  rows << [col_requester, col_created, col_updated]
end

Private Instance Methods

col_created() click to toggle source
# File lib/zend/command/ticket/show.rb, line 47
def col_created
  %Q{Created: #{ticket.created_at.getlocal.strftime("%-d %B, %H:%M")}}
end
col_requester() click to toggle source
# File lib/zend/command/ticket/show.rb, line 43
def col_requester
  "By: #{ticket.requester.name}"
end
col_subject() click to toggle source
# File lib/zend/command/ticket/show.rb, line 39
def col_subject
  "##{ticket.id}: #{ticket.subject}"
end
col_updated() click to toggle source
# File lib/zend/command/ticket/show.rb, line 51
def col_updated
  %Q{Updated: #{ticket.updated_at.getlocal.strftime("%-d %B, %H:%M")}}
end
remote_ticket(id) click to toggle source
# File lib/zend/command/ticket/show.rb, line 35
def remote_ticket(id)
  api.tickets.find(id: id, include: :users)
end