Class: PTLog::TagList
- Inherits:
-
Object
- Object
- PTLog::TagList
- Includes:
- Enumerable
- Defined in:
- lib/ptlog/git/tags_list.rb
Instance Method Summary collapse
- #each(options = {}) ⇒ Object
-
#initialize(git, since) ⇒ TagList
constructor
A new instance of TagList.
- #next_to(name) ⇒ Object
- #prev_to(name) ⇒ Object
Constructor Details
#initialize(git, since) ⇒ TagList
Returns a new instance of TagList.
5 6 7 8 9 |
# File 'lib/ptlog/git/tags_list.rb', line 5 def initialize(git, since) @list = git.lib. + ['HEAD'] @since = since @first_commit = git.lib.first_commit end |
Instance Method Details
#each(options = {}) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/ptlog/git/tags_list.rb', line 11 def each( = {}) list_after_item = @list[@list.index(@since), @list.size] if block_given? list_after_item.reverse.each { |e| yield(e) } else Enumerator.new(list_after_item.reverse, :each) end end |
#next_to(name) ⇒ Object
21 22 23 |
# File 'lib/ptlog/git/tags_list.rb', line 21 def next_to(name) @list[@list.index(name) + 1] || 'HEAD' end |
#prev_to(name) ⇒ Object
25 26 27 |
# File 'lib/ptlog/git/tags_list.rb', line 25 def prev_to(name) 0 < @list.index(name) && @list[@list.index(name) - 1] or @first_commit end |