Class: PVN::Revision::Range

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

Overview

this is of the form: -r123:456

Direct Known Subclasses

Diff::RevisionRange

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Range.



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/pvn/revision/range.rb', line 17

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

Instance Attribute Details

#fromObject (readonly)

Returns the value of attribute from.



14
15
16
# File 'lib/pvn/revision/range.rb', line 14

def from
  @from
end

#toObject (readonly)

Returns the value of attribute to.



15
16
17
# File 'lib/pvn/revision/range.rb', line 15

def to
  @to
end

Instance Method Details

#head?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/pvn/revision/range.rb', line 41

def head?
  @to == :head
end

#to_revision(val, xmllines) ⇒ Object



29
30
31
# File 'lib/pvn/revision/range.rb', line 29

def to_revision val, xmllines
  val.kind_of?(Argument) || Argument.new(val, xmllines)
end

#to_sObject



33
34
35
36
37
38
39
# File 'lib/pvn/revision/range.rb', line 33

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

#working_copy?Boolean

Returns:

  • (Boolean)


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

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