Class: P4::Revision
- Inherits:
-
Object
- Object
- P4::Revision
- 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
-
#depot_file ⇒ Object
readonly
Returns the value of attribute depot_file.
-
#integrations ⇒ Object
Returns the value of attribute integrations.
Instance Method Summary collapse
- #each_integration ⇒ Object
-
#initialize(depotFile) ⇒ Revision
constructor
A new instance of Revision.
- #integration(how, file, srev, erev) ⇒ Object
-
#method_missing(m, *a) ⇒ Object
Generic getters and setters for revision attributes.
- #set_attribute(name, value) ⇒ Object
-
#type ⇒ Object
Define #type and #type= explicitly as they clash with the deprecated Object#type.
- #type=(t) ⇒ Object
Constructor Details
#initialize(depotFile) ⇒ Revision
Returns a new instance of Revision.
570 571 572 573 574 |
# File 'lib/P4.rb', line 570 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.
614 615 616 617 618 619 620 621 622 623 624 625 |
# File 'lib/P4.rb', line 614 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_file ⇒ Object (readonly)
Returns the value of attribute depot_file.
576 577 578 |
# File 'lib/P4.rb', line 576 def depot_file @depot_file end |
#integrations ⇒ Object
Returns the value of attribute integrations.
577 578 579 |
# File 'lib/P4.rb', line 577 def integrations @integrations end |
Instance Method Details
#each_integration ⇒ Object
585 586 587 |
# File 'lib/P4.rb', line 585 def each_integration @integrations.each { |i| yield( i ) } end |
#integration(how, file, srev, erev) ⇒ Object
579 580 581 582 583 |
# File 'lib/P4.rb', line 579 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
589 590 591 592 593 594 595 596 597 598 |
# File 'lib/P4.rb', line 589 def set_attribute( name, value ) name = name.downcase if ["rev", "change", "filesize"].include?(name) @attributes[ name ] = value.to_i elsif name == "time" # If the field is the revision time, convert it to a Time object @attributes[ name ] = Time.at( value.to_i ) else @attributes[ name ] = value end end |
#type ⇒ Object
Define #type and #type= explicitly as they clash with the deprecated Object#type. As it is deprecated, this clash should disappear in time.
603 604 605 |
# File 'lib/P4.rb', line 603 def type @attributes[ 'type' ] end |
#type=(t) ⇒ Object
607 608 609 |
# File 'lib/P4.rb', line 607 def type=( t ) @attributes[ 'type' ] = t end |