ÿØÿà JFIF ÿÛ „ ( %!1!%*+...983,7(-.-
U:RDoc::NormalModule[iI"Comparable:ET@0o:RDoc::Markup::Document:@parts[o;;[
o:RDoc::Markup::Paragraph;[I"BThe Comparable mixin is used by classes whose objects may be ;TI"Cordered. The class must define the <=> operator, ;TI"Ewhich compares the receiver against another object, returning a ;TI"Jvalue less than 0, returning 0, or returning a value greater than 0, ;TI"?depending on whether the receiver is less than, equal to, ;TI"Bor greater than the other object. If the other object is not ;TI"Hcomparable then the <=> operator should return +nil+. ;TI"DComparable uses <=> to implement the conventional ;TI"<, <=, ;TI"C==, >=, and >) and the ;TI""method between?.;To:RDoc::Markup::BlankLine o:RDoc::Markup::Verbatim;[I"class SizeMatters
;TI" include Comparable
;TI" attr :str
;TI" def <=>(other)
;TI"% str.size <=> other.str.size
;TI" end
;TI" def initialize(str)
;TI" @str = str
;TI" end
;TI" def inspect
;TI" @str
;TI" end
;TI" end
;TI"
;TI"s1 = SizeMatters.new("Z")
;TI" s2 = SizeMatters.new("YY")
;TI"!s3 = SizeMatters.new("XXX")
;TI""s4 = SizeMatters.new("WWWW")
;TI"#s5 = SizeMatters.new("VVVVV")
;TI"
;TI",s1 < s2 #=> true
;TI"-s4.between?(s1, s3) #=> false
;TI",s4.between?(s3, s5) #=> true
;TI"A[ s3, s2, s5, s4, s1 ].sort #=> [Z, YY, XXX, WWWW, VVVVV]
;T:@format0S:RDoc::Markup::Heading:
leveli: textI"What's Here;T@o; ;[I"V\Module \Comparable provides these methods, all of which use method <=>:;T@o:RDoc::Markup::List:
@type:BULLET:@items[o:RDoc::Markup::ListItem:@label0;[o;;: NOTE;[o;;[I"{<}[#method-i-3C];T;[o; ;[I":Returns whether +self+ is less than the given object.;To;;0;[o;;;;[o;;[I"{<=}[#method-i-3C-3D];T;[o; ;[I"5Returns whether +self+ is less than or equal to ;TI"the given object.;To;;0;[o;;;;[o;;[I"{==}[#method-i-3D-3D];T;[o; ;[I"9Returns whether +self+ is equal to the given object.;To;;0;[o;;;;[o;;[I"{>}[#method-i-3E];T;[o; ;[I"8Returns whether +self+ is greater than or equal to ;TI"the given object.;To;;0;[o;;;;[o;;[I"{>=}[#method-i-3E-3D];T;[o; ;[I"=Returns whether +self+ is greater than the given object.;To;;0;[o; ;[I"E#between? Returns +true+ if +self+ is between two given objects.;To;;0;[o;;;;[o;;[I"#clamp;T;[o; ;[I"NFor given objects +min+ and +max+, or range (min..max), returns:;To;;;;[o;;0;[o; ;[I"*+min+ if (self <=> min) < 0.;To;;0;[o; ;[I"*+max+ if (self <=> max) > 0.;To;;0;[o; ;[I"+self+ otherwise.;T:
@fileI"
compar.c;T:0@omit_headings_from_table_of_contents_below0;0;0[ [ [ [[I"
class;T[[:public[ [:protected[ [:private[ [I"
instance;T[[;[ [;[ [;[[I"<;TI"
compar.c;T[I"<=;T@[I"==;T@[I">;T@[I">=;T@[I"
between?;T@[I"
clamp;T@[ [U:RDoc::Context::Section[i 0o;;[ ;0;0[I"
compar.c;T@cRDoc::TopLevel