Class: Jirify::UI::IssueRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/jirify/ui/issue_renderer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(issue) ⇒ IssueRenderer

Returns a new instance of IssueRenderer.



8
9
10
# File 'lib/jirify/ui/issue_renderer.rb', line 8

def initialize(issue)
  @issue = issue
end

Instance Attribute Details

#issueObject (readonly)

Returns the value of attribute issue.



6
7
8
# File 'lib/jirify/ui/issue_renderer.rb', line 6

def issue
  @issue
end

Instance Method Details

#as_card(options) ⇒ Object



28
29
30
31
32
33
# File 'lib/jirify/ui/issue_renderer.rb', line 28

def as_card(options)
  card = as_table_cell(options)
  Terminal::Table.new(rows: [[card]])
rescue RuntimeError
  raise UI::WindowTooNarrow, 'The terminal window is too narrow.'
end

#as_table_cell(options) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/jirify/ui/issue_renderer.rb', line 12

def as_table_cell(options)
  options[:max_length] ||= IO.console.winsize[1] - 4
  options[:summary]    ||= false
  options[:url]        ||= false
  options[:assignee]   ||= false

  raise UI::WindowTooNarrow, 'The terminal window is too narrow.' if options[:max_length] <= key.size

  row = ''
  row << "#{ColorizedString[key].bold}"
  row << summary_line(options)  if show_summary?(options)
  row << url_line               if show_url?(options)
  row << assignee_line(options) if show_assignee?(options)
  row
end