⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.133
Server IP:
185.119.109.197
Server:
Linux managedhosting.chostar.me 5.15.0-160-generic #170-Ubuntu SMP Wed Oct 1 10:06:56 UTC 2025 x86_64
Server Software:
Apache
PHP Version:
8.1.33
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
usr
/
share
/
ri
/
3.0.0
/
system
/
Range
/
View File Name :
cdesc-Range.ri
U:RDoc::NormalClass[iI" Range:ET@I"Object;To:RDoc::Markup::Document:@parts[o;;[ : @fileI"#ext/json/lib/json/add/range.rb;T:0@omit_headings_from_table_of_contents_below0o;;[#o:RDoc::Markup::Paragraph;[ I"=A Range represents an interval---a set of values with a ;TI"?beginning and an end. Ranges may be constructed using the ;TI"-
s
..
e
and ;TI"<
s
...
e
literals, or with ;TI":Range::new. Ranges constructed using
..
;TI"Hrun from the beginning to the end inclusively. Those created using ;TI"G
...
exclude the end value. When used as an iterator, ;TI".ranges return each value in the sequence.;To:RDoc::Markup::BlankLine o:RDoc::Markup::Verbatim;[ I"(-1..-5).to_a #=> [] ;TI"1(-5..-1).to_a #=> [-5, -4, -3, -2, -1] ;TI"6('a'..'e').to_a #=> ["a", "b", "c", "d", "e"] ;TI"1('a'...'e').to_a #=> ["a", "b", "c", "d"] ;T:@format0S:RDoc::Markup::Heading: leveli: textI"Beginless/Endless Ranges;T@o;;[I"HA "beginless range" and "endless range" represents a semi-infinite ;TI"7range. Literal notation for a beginless range is:;T@o; ;[I"(..1) ;TI" # or ;TI"(...1) ;T;0o;;[I".Literal notation for an endless range is:;T@o; ;[I"(1..) ;TI"# or similarly ;TI"(1...) ;T;0o;;[I"Which is equivalent to;T@o; ;[I"((1..nil) # or similarly (1...nil) ;TI"4Range.new(1, nil) # or Range.new(1, nil, true) ;T;0o;;[I"EBeginless/endless ranges are useful, for example, for idiomatic ;TI"slicing of arrays:;T@o; ;[I")[1, 2, 3, 4, 5][...2] # => [1, 2] ;TI",[1, 2, 3, 4, 5][2...] # => [3, 4, 5] ;T;0o;;[I"!Some implementation details:;T@o:RDoc::Markup::List: @type:BULLET:@items[ o:RDoc::Markup::ListItem:@label0;[o;;[I"E+begin+ of beginless range and +end+ of endless range are +nil+;;To;;0;[o;;[I"3+each+ of beginless range raises an exception;;To;;0;[o;;[I"B+each+ of endless range enumerates infinite sequence (may be ;TI"Auseful in combination with Enumerable#take_while or similar ;TI"methods);;To;;0;[o;;[I"?
(1..)
and
(1...)
are not equal, ;TI"9although technically representing the same sequence.;T@S;;i;I"Custom Objects in Ranges;T@o;;[I"FRanges can be constructed using any objects that can be compared ;TI"*using the
<=>
operator. ;TI"MMethods that treat the range as a sequence (#each and methods inherited ;TI"=from Enumerable) expect the begin object to implement a ;TI"E
succ
method to return the next object in sequence. ;TI"7The #step and #include? methods require the begin ;TI"
succ or to be numeric.;T@o;;[ I"BIn the
Xs
class below both
<=>
and ;TI"F
succ
are implemented so
Xs
can be used ;TI"Fto construct ranges. Note that the Comparable module is included ;TI"Kso the
==
method is defined in terms of
<=>
.;T@o; ;[I":class Xs # represent a string of 'x's ;TI" include Comparable ;TI" attr :length ;TI" def initialize(n) ;TI" @length = n ;TI" end ;TI" def succ ;TI" Xs.new(@length + 1) ;TI" end ;TI" def <=>(other) ;TI"" @length <=> other.length ;TI" end ;TI" def to_s ;TI"+ sprintf "%2d #{inspect}", @length ;TI" end ;TI" def inspect ;TI" 'x' * @length ;TI" end ;TI" end ;T;0o;;[I">An example of using
Xs
to construct a range:;T@o; ;[I"0r = Xs.new(3)..Xs.new(6) #=> xxx..xxxxxx ;TI"?r.to_a #=> [xxx, xxxx, xxxxx, xxxxxx] ;TI"(r.member?(Xs.new(5)) #=> true;T;0; I"range.c;T; 0; 0; 0[ [ [[I"Enumerable;To;;[ ; @; 0I"range.c;T[[I" class;T[[:public[[I"json_create;TI"#ext/json/lib/json/add/range.rb;T[I"new;T@[:protected[ [:private[ [I" instance;T[[;[ [I"%;T@[I"==;T@[I"===;T@[I"as_json;T@[I" begin;T@[I"bsearch;T@[I" count;T@[I"cover?;T@[I" each;T@[I"end;T@[I"entries;T@[I" eql?;T@[I"exclude_end?;T@[I" first;T@[I" hash;T@[I" include?;T@[I"inspect;T@[I" last;T@[I"max;T@[I"member?;T@[I"min;T@[I"minmax;T@[I" size;T@[I" step;T@[I" to_a;T@[I"to_json;T@[I" to_s;T@[;[ [;[ [ [U:RDoc::Context::Section[i 0o;;[ ; 0; 0[@ I"lib/pp.rb;T@@cRDoc::TopLevel