lib/bio/location.rb in bio-1.4.0 vs lib/bio/location.rb in bio-1.4.1

- old
+ new

@@ -177,10 +177,32 @@ return 1 end return 0 end + # If _other_ is equal with the self, returns true. + # Otherwise, returns false. + # --- + # *Arguments*: + # * (required) _other_: any object + # *Returns*:: true or false + def ==(other) + return true if super(other) + return false unless other.instance_of?(self.class) + flag = false + [ :from, :to, :strand, :sequence, :lt, :gt, + :xref_id, :carat ].each do |m| + begin + flag = (self.__send__(m) == other.__send__(m)) + rescue NoMethodError, ArgumentError, NameError + flag = false + end + break unless flag + end + flag + end + end # Location # == Description # # The Bio::Locations class is a container for Bio::Location objects: @@ -345,9 +367,26 @@ end if self.sort == other.sort return true else return false + end + end + + # If _other_ is equal with the self, returns true. + # Otherwise, returns false. + # --- + # *Arguments*: + # * (required) _other_: any object + # *Returns*:: true or false + def ==(other) + return true if super(other) + return false unless other.instance_of?(self.class) + if self.locations == other.locations and + self.operator == other.operator then + true + else + false end end # Iterates on each Bio::Location object. def each