Class: Git::Switcher::Menu::MenuItem
- Inherits:
-
Struct
- Object
- Struct
- Git::Switcher::Menu::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
12 13 14 |
# File 'lib/git/switcher/menu.rb', line 12 def next @next end |
#reference ⇒ Object
Returns the value of attribute reference
12 13 14 |
# File 'lib/git/switcher/menu.rb', line 12 def reference @reference end |
#repo ⇒ Object
Returns the value of attribute repo
12 13 14 |
# File 'lib/git/switcher/menu.rb', line 12 def repo @repo end |
#shortcut ⇒ Object
Returns the value of attribute shortcut
12 13 14 |
# File 'lib/git/switcher/menu.rb', line 12 def shortcut @shortcut end |
Instance Method Details
#head? ⇒ Boolean
15 16 17 |
# File 'lib/git/switcher/menu.rb', line 15 def head? reference.targets?(repo.head) end |
#to_s ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/git/switcher/menu.rb', line 19 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 |