Class: P4::Revision

Inherits:
Object
  • Object
show all
Defined in:
lib/P4.rb

Overview

***************************************************************************** P4::Revision class Each P4::Revision object holds details about a particular revision of a file. It may also contain the history of any integrations to/from the file *****************************************************************************

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(depotFile) ⇒ Revision

Returns a new instance of Revision.



456
457
458
459
460
# File 'lib/P4.rb', line 456

def initialize( depotFile )
  @depot_file = depotFile
  @integrations = Array.new
  @attributes = Hash.new
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *a) ⇒ Object

Generic getters and setters for revision attributes.



498
499
500
501
502
503
504
505
506
507
508
509
# File 'lib/P4.rb', line 498

def method_missing( m, *a )
  k = m.to_s.downcase
  if( k =~ /(.*)=$/ )
	if( a.length() == 0 )
	  raise( P4Exception, "Method P4##{m} requires an argument" );
	end
	k = $1
	@attributes[ k ] = a.shift
  else
	@attributes[ k ]
  end
end

Instance Attribute Details

#depot_fileObject (readonly)

Returns the value of attribute depot_file.



462
463
464
# File 'lib/P4.rb', line 462

def depot_file
  @depot_file
end

#integrationsObject

Returns the value of attribute integrations.



463
464
465
# File 'lib/P4.rb', line 463

def integrations
  @integrations
end

Instance Method Details

#each_integrationObject



471
472
473
# File 'lib/P4.rb', line 471

def each_integration
  @integrations.each { |i| yield( i ) }
end

#integration(how, file, srev, erev) ⇒ Object



465
466
467
468
469
# File 'lib/P4.rb', line 465

def integration( how, file, srev, erev )
  rec = P4::Integration.new( how, file, srev, erev )
  @integrations.push( rec )
  return rec
end

#set_attribute(name, value) ⇒ Object



475
476
477
478
479
480
481
482
# File 'lib/P4.rb', line 475

def set_attribute( name, value )
  name = name.downcase
  if( value =~ /^\d+$/ )
	@attributes[ name ] = value.to_i
  else
	@attributes[ name ] = value
  end
end

#typeObject

Define #type and #type= explicitly as they clash with the deprecated Object#type. As it is deprecated, this clash should disappear in time.



487
488
489
# File 'lib/P4.rb', line 487

def type
	@attributes[ 'type' ]
end

#type=(t) ⇒ Object



491
492
493
# File 'lib/P4.rb', line 491

def type=( t )
	@attributes[ 'type' ] = t
end