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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# 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?)
shortcuts = (1..Float::INFINITY).each
= [
('REMOTE BRANCHES', remote_branches, shortcuts),
('LOCAL BRANCHES', local_branches, shortcuts),
('TAGS', @repo.tags, shortcuts),
].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
54
55
56
|
# File 'lib/git/switcher/menu.rb', line 54
def [](shortcut)
@lookup[shortcut]
end
|
62
63
64
|
# File 'lib/git/switcher/menu.rb', line 62
def
&.next
end
|
58
59
60
|
# File 'lib/git/switcher/menu.rb', line 58
def
.find(&:head?)
end
|
#to_s ⇒ Object
66
67
68
|
# File 'lib/git/switcher/menu.rb', line 66
def to_s
.join("\n")
end
|