Class: Git::BlameColor::Formatter

Inherits:
Object
  • Object
show all
Defined in:
lib/git-blame-color/formatter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(author_name_width, line_number_width, options = {}) ⇒ Formatter

Returns a new instance of Formatter.



9
10
11
12
13
# File 'lib/git-blame-color/formatter.rb', line 9

def initialize(author_name_width, line_number_width, options={})
  @author_name_width = author_name_width
  @line_number_width = line_number_width
  @options = options
end

Instance Attribute Details

#author_name_widthObject (readonly)

Returns the value of attribute author_name_width.



7
8
9
# File 'lib/git-blame-color/formatter.rb', line 7

def author_name_width
  @author_name_width
end

#line_number_widthObject (readonly)

Returns the value of attribute line_number_width.



7
8
9
# File 'lib/git-blame-color/formatter.rb', line 7

def line_number_width
  @line_number_width
end

Instance Method Details

#format(commit) ⇒ Object



27
28
29
30
31
32
33
34
35
36
# File 'lib/git-blame-color/formatter.rb', line 27

def format(commit)
  parts = [
    color_coded_hash(commit),
    Rainbow(author_to_s(commit)).blue,
    Rainbow(timestamp_to_s(commit)).green,
    Rainbow(line_number_to_s(commit)).black.bright,
    commit.edited_line
  ]
  parts.join(' ')
end

#long_hashes?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/git-blame-color/formatter.rb', line 15

def long_hashes?
  !!@options[:long_hashes]
end

#raw_timestamps?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/git-blame-color/formatter.rb', line 23

def raw_timestamps?
  !!@options[:raw_timestamps]
end

#show_boundary_commits?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/git-blame-color/formatter.rb', line 19

def show_boundary_commits?
  @options.include?(:show_boundary_commits) ? !!@options[:show_boundary_commits] : true
end