Class: Circler::ProjectPrinter

Inherits:
Object
  • Object
show all
Defined in:
lib/circler/printer/project_printer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(projects, compact: false) ⇒ ProjectPrinter

Returns a new instance of ProjectPrinter.



4
5
6
7
# File 'lib/circler/printer/project_printer.rb', line 4

def initialize(projects, compact: false)
  @projects = projects
  @compact = compact
end

Instance Attribute Details

#compactObject

Returns the value of attribute compact.



3
4
5
# File 'lib/circler/printer/project_printer.rb', line 3

def compact
  @compact
end

Instance Method Details

#to_sObject



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/circler/printer/project_printer.rb', line 9

def to_s
  if compact
    @projects.map(&:name_array)
  else
    Terminal::Table.new(
      title: 'Projects'.green,
      headings: ['User name', 'Repository name'],
      rows: @projects.map(&:information)
    ).to_s
  end
end