Class: PTLog::TagList
- Inherits:
-
Object
- Object
- PTLog::TagList
- Includes:
- Enumerable
- Defined in:
- lib/ptlog/change_log.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.
21 22 23 24 25 |
# File 'lib/ptlog/change_log.rb', line 21 def initialize(git, since) @list = git.lib. @since = since @first_commit = git.lib.first_commit end |
Instance Method Details
#each(options = {}) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/ptlog/change_log.rb', line 27 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
37 38 39 |
# File 'lib/ptlog/change_log.rb', line 37 def next_to(name) @list[@list.index(name) + 1] || 'HEAD' end |
#prev_to(name) ⇒ Object
41 42 43 |
# File 'lib/ptlog/change_log.rb', line 41 def prev_to(name) 0 < @list.index(name) && @list[@list.index(name) - 1] or @first_commit end |