Class: Git::Switcher::Menu::MenuItem

Inherits:
Struct
  • Object
show all
Defined in:
lib/git/switcher/menu.rb

Constant Summary collapse

HEAD =
Rainbow(' <- HEAD ***').bold.aquamarine.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nextObject

Returns the value of attribute next

Returns:

  • (Object)

    the current value of next



12
13
14
# File 'lib/git/switcher/menu.rb', line 12

def next
  @next
end

#referenceObject

Returns the value of attribute reference

Returns:

  • (Object)

    the current value of reference



12
13
14
# File 'lib/git/switcher/menu.rb', line 12

def reference
  @reference
end

#repoObject

Returns the value of attribute repo

Returns:

  • (Object)

    the current value of repo



12
13
14
# File 'lib/git/switcher/menu.rb', line 12

def repo
  @repo
end

#shortcutObject

Returns the value of attribute shortcut

Returns:

  • (Object)

    the current value of shortcut



12
13
14
# File 'lib/git/switcher/menu.rb', line 12

def shortcut
  @shortcut
end

Instance Method Details

#head?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/git/switcher/menu.rb', line 15

def head?
  reference.targets?(repo.head)
end

#to_sObject



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