Class: Git::Switcher::Menu
- Inherits:
-
Object
- Object
- Git::Switcher::Menu
show all
- Defined in:
- lib/git/switcher/menu.rb
Defined Under Namespace
Classes: MenuItem, Submenu
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(repo) ⇒ Menu
Returns a new instance of Menu.
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/git/switcher/menu.rb', line 35
def initialize(repo)
@repo = repo
remote_branches = @repo.branches.find_all(&:remote?)
local_branches = @repo.branches.find_all(&:local?)
= [
('REMOTE BRANCHES', remote_branches, shortcuts('a')),
('LOCAL BRANCHES', local_branches, shortcuts(1)),
('TAGS', @repo.tags, shortcuts(100)),
].compact
= .map(&:menu_items).flatten
@lookup = Hash[.map(&:shortcut).zip()]
end
|
Class Method Details
.for(repo) ⇒ Object
31
32
33
|
# File 'lib/git/switcher/menu.rb', line 31
def self.for(repo)
new(repo)
end
|
Instance Method Details
#[](shortcut) ⇒ Object
52
53
54
|
# File 'lib/git/switcher/menu.rb', line 52
def [](shortcut)
@lookup[shortcut]
end
|
60
61
62
|
# File 'lib/git/switcher/menu.rb', line 60
def
&.next
end
|
56
57
58
|
# File 'lib/git/switcher/menu.rb', line 56
def
.find(&:head?)
end
|
#to_s ⇒ Object
64
65
66
|
# File 'lib/git/switcher/menu.rb', line 64
def to_s
.join("\n")
end
|