Class: GitWaybackMachine::History::Entry

Inherits:
Struct
  • Object
show all
Defined in:
lib/git_wayback_machine/history.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#commentObject

Returns the value of attribute comment



10
11
12
# File 'lib/git_wayback_machine/history.rb', line 10

def comment
  @comment
end

#nameObject

Returns the value of attribute name



10
11
12
# File 'lib/git_wayback_machine/history.rb', line 10

def name
  @name
end

#shaObject

Returns the value of attribute sha



10
11
12
# File 'lib/git_wayback_machine/history.rb', line 10

def sha
  @sha
end

#timeObject

Returns the value of attribute time



10
11
12
# File 'lib/git_wayback_machine/history.rb', line 10

def time
  @time
end

Instance Method Details

#to_sObject



11
12
13
14
15
16
17
18
19
# File 'lib/git_wayback_machine/history.rb', line 11

def to_s
  meta           = "\e[33m#{sha}\e[37m | \e[35m#{name.ljust(17)} \e[36m(#{time})\e[37m - "
  size_so_far    = meta.gsub(/\e\[\d+m/, "").size
  terminal_width = `tput cols`.to_i
  cut_comment    = comment.slice(0, terminal_width - size_so_far - 3)
  cut_comment << "…" if comment.size > cut_comment.size

  "#{meta}#{cut_comment}\e[0m"
end