Class: CodelessCode::Renderers::Fable

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/codeless_code/renderers/fable.rb

Overview

Prints a Fable is various ways.

Constant Summary collapse

HEADER_SORT =
%w[Tagline Number Date].freeze

Instance Method Summary collapse

Instance Method Details

#best_titleObject


38
39
40
41
42
# File 'lib/codeless_code/renderers/fable.rb', line 38

def best_title
  return title_with_subtitle if title&.size&.positive?

  self['Name'] || self['Tagline'] || inspect
end

#for_list(head_keys = [], title_width: '') ⇒ Object


33
34
35
36
# File 'lib/codeless_code/renderers/fable.rb', line 33

def for_list(head_keys = [], title_width: '')
  format("%s  %#{title_width}s    %s",
         wide_number, best_title, render_slice(head_keys)).strip
end

#for_pager(format, fallback: nil) ⇒ Object


24
25
26
27
28
29
30
31
# File 'lib/codeless_code/renderers/fable.rb', line 24

def for_pager(format, fallback: nil)
  TermPage.new.tap do |page|
    page.title = best_title
    page.body = render_with(format, fallback: fallback)

    headers_no_best_title.map { |key, val| page.add_header(key, val) }
  end
end