Class: HustleAndFlow::Formatters::BranchTableFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/hustle_and_flow/formatters/branch_table_formatter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(branches) ⇒ BranchTableFormatter

Returns a new instance of BranchTableFormatter.



6
7
8
# File 'lib/hustle_and_flow/formatters/branch_table_formatter.rb', line 6

def initialize(branches)
  self.branches = branches
end

Instance Attribute Details

#branchesObject

Returns the value of attribute branches.



4
5
6
# File 'lib/hustle_and_flow/formatters/branch_table_formatter.rb', line 4

def branches
  @branches
end

Instance Method Details

#to_aryObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/hustle_and_flow/formatters/branch_table_formatter.rb', line 10

def to_ary
  number = 0

  branches.map do |branch|
    [
      {
        format: number_formatting(branch),
        value:  number += 1,
      },
      {
        format: current_branch_formatting(branch),
        value:  branch.current? ? '*' : ' ',
      },
      {
        format: status_formatting(branch),
        value:  status(branch),
      },
      {
        format: author_formatting(branch),
        value:  branch.author,
      },
      {
        format: name_formatting(branch),
        value:  branch.name,
      },
    ]
  end
end