Class: SVNx::Revision::RelativeArgument
- Inherits:
-
IndexArgument
- Object
- Argument
- IndexArgument
- SVNx::Revision::RelativeArgument
- Defined in:
- lib/svnx/revision/argument.rb
Overview
this is of the form -3, which is revision (second one from the most recent; -1 is the most recent).
Instance Attribute Summary
Attributes inherited from Argument
Instance Method Summary collapse
-
#initialize(value, args) ⇒ RelativeArgument
constructor
A new instance of RelativeArgument.
Methods inherited from Argument
Constructor Details
#initialize(value, args) ⇒ RelativeArgument
Returns a new instance of RelativeArgument.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/svnx/revision/argument.rb', line 58 def initialize value, args entries = args[:entries] unless entries raise RevisionError.new "cannot determine relative revision without entries" end nentries = entries.size # logentries are in descending order, so the most recent one is index 0 if value.abs > nentries raise RevisionError.new "ERROR: no entry for revision: #{value.abs}; number of entries: #{nentries}" else idx = value < 0 ? value.abs - 1 : nentries - value log_entry = entries[idx] super log_entry.revision.to_i end end |