Class: Svnx::Revision::Range

Inherits:
Object
  • Object
show all
Includes:
Logue::Loggable
Defined in:
lib/svnx/revision/range.rb

Overview

this is of the form: -r123:456

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(from, to = nil, entries = nil) ⇒ Range

Returns a new instance of Range.



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/svnx/revision/range.rb', line 21

def initialize from, to = nil, entries = nil
  if to
    @from = to_revision from, entries
    @to = to_revision to, entries
  elsif from.kind_of? String
    @from, @to = from.split(':').collect { |x| to_revision x, entries }
  else
    @from = to_revision from, entries
    @to = :working_copy
  end
end

Instance Attribute Details

#fromObject (readonly)

Returns the value of attribute from.



18
19
20
# File 'lib/svnx/revision/range.rb', line 18

def from
  @from
end

#toObject (readonly)

Returns the value of attribute to.



19
20
21
# File 'lib/svnx/revision/range.rb', line 19

def to
  @to
end

Instance Method Details

#head?Boolean

Returns:

  • (Boolean)


45
46
47
48
# File 'lib/svnx/revision/range.rb', line 45

def head?
  # return true/false instead of true/false/nil
  @to ? @to.value == 'HEAD' : false
end

#to_revision(val, entries) ⇒ Object



33
34
35
# File 'lib/svnx/revision/range.rb', line 33

def to_revision val, entries
  val.kind_of?(Argument) ? val : Argument.create(val, entries: entries)
end

#to_sObject



37
38
39
40
41
42
43
# File 'lib/svnx/revision/range.rb', line 37

def to_s
  str = @from.to_s
  unless working_copy?
    str << ':' << @to.to_s
  end
  str
end

#working_copy?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/svnx/revision/range.rb', line 50

def working_copy?
  @to == nil || @to == :wc || @to == :working_copy
end