Class: Git::Switcher::MenuItem
- Inherits:
-
Struct
- Object
- Struct
- Git::Switcher::MenuItem
- Defined in:
- lib/git/switcher/menu.rb
Constant Summary collapse
- HEAD =
Rainbow(' <- HEAD ***').bold.aquamarine.freeze
Instance Attribute Summary collapse
-
#next ⇒ Object
Returns the value of attribute next.
-
#reference ⇒ Object
Returns the value of attribute reference.
-
#repo ⇒ Object
Returns the value of attribute repo.
-
#shortcut ⇒ Object
Returns the value of attribute shortcut.
Instance Method Summary collapse
Instance Attribute Details
#next ⇒ Object
Returns the value of attribute next
11 12 13 |
# File 'lib/git/switcher/menu.rb', line 11 def next @next end |
#reference ⇒ Object
Returns the value of attribute reference
11 12 13 |
# File 'lib/git/switcher/menu.rb', line 11 def reference @reference end |
#repo ⇒ Object
Returns the value of attribute repo
11 12 13 |
# File 'lib/git/switcher/menu.rb', line 11 def repo @repo end |
#shortcut ⇒ Object
Returns the value of attribute shortcut
11 12 13 |
# File 'lib/git/switcher/menu.rb', line 11 def shortcut @shortcut end |
Instance Method Details
#head? ⇒ Boolean
14 15 16 |
# File 'lib/git/switcher/menu.rb', line 14 def head? reference.targets?(repo.head) end |
#to_s ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/git/switcher/menu.rb', line 18 def to_s name = reference.name label = format('[%2s]', shortcut) format( " %<label>s\t%<name>s%<head>s", label: head? ? Rainbow(label).bold : label, name: head? ? Rainbow(name).inverse : name, head: head? ? HEAD : '', ) end |