D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
ENV
/
Filename :
cdesc-ENV.ri
back
Copy
U:RDoc::NormalClass[iI"ENV:ET@I"Object;To:RDoc::Markup::Document:@parts[o;;[@o:RDoc::Markup::Paragraph;[I"=+ENV+ is a hash-like accessor for environment variables.;To:RDoc::Markup::BlankLine S:RDoc::Markup::Heading: leveli: textI"*Interaction with the Operating System;T@o; ;[I"RThe +ENV+ object interacts with the operating system's environment variables:;T@o:RDoc::Markup::List: @type:BULLET:@items[o:RDoc::Markup::ListItem:@label0;[o; ;[I"uWhen you get the value for a name in +ENV+, the value is retrieved from among the current environment variables.;To;;0;[o; ;[I"|When you create or set a name-value pair in +ENV+, the name and value are immediately set in the environment variables.;To;;0;[o; ;[I"jWhen you delete a name-value pair in +ENV+, it is immediately deleted from the environment variables.;T@S;;i; I"Names and Values;T@o; ;[I",Generally, a name or value is a String.;T@S;;i ; I"Valid Names and Values;T@o; ;[I"5Each name or value must be one of the following:;T@o;;;;[o;;0;[o; ;[I"A String.;To;;0;[o; ;[I"|An object that responds to \#to_str by returning a String, in which case that String will be used as the name or value.;T@S;;i ; I"Invalid Names and Values;T@o; ;[I"A new name:;T@o;;;;[o;;0;[o; ;[I"!May not be the empty string:;To:RDoc::Markup::Verbatim;[I"ENV[''] = '0' ;TI"?# Raises Errno::EINVAL (Invalid argument - ruby_setenv()) ;T:@format0o;;0;[o; ;[I"0May not contain character <code>"="</code>:;To;;[I"ENV['='] = '0' ;TI"@# Raises Errno::EINVAL (Invalid argument - ruby_setenv(=)) ;T;0o; ;[I"A new name or value:;T@o;;;;[o;;0;[o; ;[I"?May not be a non-String that does not respond to \#to_str:;T@o;;[ I"ENV['foo'] = Object.new ;TI"G# Raises TypeError (no implicit conversion of Object into String) ;TI"ENV[Object.new] = '0' ;TI"G# Raises TypeError (no implicit conversion of Object into String) ;T;0o;;0;[o; ;[I"9May not contain the NUL character <code>"\0"</code>:;T@o;;[ I"ENV['foo'] = "\0" ;TI"Q# Raises ArgumentError (bad environment variable value: contains null byte) ;TI"ENV["\0"] == '0' ;TI"P# Raises ArgumentError (bad environment variable name: contains null byte) ;T;0o;;0;[o; ;[I"QMay not have an ASCII-incompatible encoding such as UTF-16LE or ISO-2022-JP:;T@o;;[ I"<ENV['foo'] = '0'.force_encoding(Encoding::ISO_2022_JP) ;TI"f# Raises ArgumentError (bad environment variable name: ASCII incompatible encoding: ISO-2022-JP) ;TI"<ENV["foo".force_encoding(Encoding::ISO_2022_JP)] = '0' ;TI"f# Raises ArgumentError (bad environment variable name: ASCII incompatible encoding: ISO-2022-JP) ;T;0S;;i; I"About Ordering;T@o; ;[I">+ENV+ enumerates its name/value pairs in the order found ;TI"6in the operating system's environment variables. ;TI"WTherefore the ordering of +ENV+ content is OS-dependent, and may be indeterminate.;T@o; ;[I"This will be seen in:;To;;;;[o;;0;[o; ;[I"(A Hash returned by an +ENV+ method.;To;;0;[o; ;[I"/An Enumerator returned by an +ENV+ method.;To;;0;[o; ;[I"<An Array returned by ENV.keys, ENV.values, or ENV.to_a.;To;;0;[o; ;[I"(The String returned by ENV.inspect.;To;;0;[o; ;[I"%The Array returned by ENV.shift.;To;;0;[o; ;[I""The name returned by ENV.key.;T@S;;i; I"About the Examples;To; ;[I"aSome methods in +ENV+ return +ENV+ itself. Typically, there are many environment variables. ;TI"DIt's not useful to display a large +ENV+ in the examples here, ;TI"Gso most example snippets begin by resetting the contents of +ENV+:;To;;;;[o;;0;[o; ;[I"AENV.replace replaces +ENV+ with a new collection of entries.;To;;0;[o; ;[I"ENV.clear empties +ENV+.;T@S;;i; I"What's Here;T@o; ;[I"+First, what's elsewhere. \Class +ENV+:;T@o;;;;[o;;0;[o; ;[I"AInherits from {class Object}[rdoc-ref:Object@What-27s+Here].;To;;0;[o; ;[I"DExtends {module Enumerable}[rdoc-ref:Enumerable@What-27s+Here],;T@o; ;[I"<Here, class +ENV+ provides methods that are useful for:;T@o;;;;[o;;0;[o; ;[I"2{Querying}[rdoc-ref:ENV@Methods+for+Querying];To;;0;[o; ;[I"4{Assigning}[rdoc-ref:ENV@Methods+for+Assigning];To;;0;[o; ;[I"2{Deleting}[rdoc-ref:ENV@Methods+for+Deleting];To;;0;[o; ;[I"4{Iterating}[rdoc-ref:ENV@Methods+for+Iterating];To;;0;[o; ;[I"6{Converting}[rdoc-ref:ENV@Methods+for+Converting];To;;0;[o; ;[I"/{And more ....}[rdoc-ref:ENV@More+Methods];T@S;;i ; I"Methods for Querying;T@o;;;;[o;;0;[o; ;[I"R::[]: Returns the value for the given environment variable name if it exists:;To;;0;[o; ;[I".::empty?: Returns whether +ENV+ is empty.;To;;0;[o; ;[I"I::has_value?, ::value?: Returns whether the given value is in +ENV+.;To;;0;[o; ;[I"O::include?, ::has_key?, ::key?, ::member?: Returns whether the given name ;TI"is in +ENV+.;To;;0;[o; ;[I"E::key: Returns the name of the first entry with the given value.;To;;0;[o; ;[I"5::size, ::length: Returns the number of entries.;To;;0;[o; ;[I"=::value?: Returns whether any entry has the given value.;T@S;;i ; I"Methods for Assigning;T@o;;;;[ o;;0;[o; ;[I"Q::[]=, ::store: Creates, updates, or deletes the named environment variable.;To;;0;[o; ;[I"@::clear: Removes every environment variable; returns +ENV+:;To;;0;[o; ;[I"M::update, ::merge!: Adds to +ENV+ each key/value pair in the given hash.;To;;0;[o; ;[I"9::replace: Replaces the entire content of the +ENV+ ;TI"1with the name/value pairs in the given hash.;T@S;;i ; I"Methods for Deleting;T@o;;;;[o;;0;[o; ;[I"H::delete: Deletes the named environment variable name if it exists.;To;;0;[o; ;[I"8::delete_if: Deletes entries selected by the block.;To;;0;[o; ;[I":::keep_if: Deletes entries not selected by the block.;To;;0;[o; ;[I"O::reject!: Similar to #delete_if, but returns +nil+ if no change was made.;To;;0;[o; ;[I"A::select!, ::filter!: Deletes entries selected by the block.;To;;0;[o; ;[I"2::shift: Removes and returns the first entry.;T@S;;i ; I"Methods for Iterating;T@o;;;;[o;;0;[o; ;[I"D::each, ::each_pair: Calls the block with each name/value pair.;To;;0;[o; ;[I"0::each_key: Calls the block with each name.;To;;0;[o; ;[I"3::each_value: Calls the block with each value.;T@S;;i ; I"Methods for Converting;T@o;;;;[o;;0;[o; ;[I"F::assoc: Returns a 2-element array containing the name and value ;TI"4of the named environment variable if it exists:;To;;0;[o; ;[I"3::clone: Returns +ENV+ (and issues a warning).;To;;0;[o; ;[I"I::except: Returns a hash of all name/value pairs except those given.;To;;0;[o; ;[I"3::fetch: Returns the value for the given name.;To;;0;[o; ;[I":::inspect: Returns the contents of +ENV+ as a string.;To;;0;[o; ;[I"?::invert: Returns a hash whose keys are the +ENV+ values, ;TI"8and whose values are the corresponding +ENV+ names.;To;;0;[o; ;[I"+::keys: Returns an array of all names.;To;;0;[o; ;[I"C::rassoc: Returns the name and value of the first found entry ;TI"that has the given value.;To;;0;[o; ;[I"I::reject: Returns a hash of those entries not rejected by the block.;To;;0;[o; ;[I"R::select, ::filter: Returns a hash of name/value pairs selected by the block.;To;;0;[o; ;[I"O::slice: Returns a hash of the given names and their corresponding values.;To;;0;[o; ;[I"A::to_a: Returns the entries as an array of 2-element Arrays.;To;;0;[o; ;[I"=::to_h: Returns a hash of entries selected by the block.;To;;0;[o; ;[I".::to_hash: Returns a hash of all entries.;To;;0;[o; ;[I"/::to_s: Returns the string <tt>'ENV'</tt>.;To;;0;[o; ;[I".::values: Returns all values as an array.;To;;0;[o; ;[I"D::values_at: Returns an array of the values for the given name.;T@S;;i ; I"More Methods;T@o;;;;[o;;0;[o; ;[I" ::dup: Raises an exception.;To;;0;[o; ;[I"#::freeze: Raises an exception.;To;;0;[o; ;[I"6::rehash: Returns +nil+, without modifying +ENV+.;T: @fileI"hash.c;T:0@omit_headings_from_table_of_contents_below0;0;0[ [ [ [[I" class;T[[:public[6[I"[];TI"hash.c;T[I"[]=;T@�[I" assoc;T@�[I" clear;T@�[I" clone;T@�[I"delete;T@�[I"delete_if;T@�[I"dup;T@�[I" each;T@�[I" each_key;T@�[I"each_pair;T@�[I"each_value;T@�[I"empty?;T@�[I"except;T@�[I" fetch;T@�[I"filter;T@�[I"filter!;T@�[I"freeze;T@�[I" has_key?;T@�[I"has_value?;T@�[I" include?;T@�[I"inspect;T@�[I"invert;T@�[I"keep_if;T@�[I"key;T@�[I" key?;T@�[I" keys;T@�[I"length;T@�[I"member?;T@�[I"merge!;T@�[I"rassoc;T@�[I"rehash;T@�[I"reject;T@�[I"reject!;T@�[I"replace;T@�[I"select;T@�[I"select!;T@�[I" shift;T@�[I" size;T@�[I" slice;T@�[I" store;T@�[I" to_a;T@�[I" to_h;T@�[I"to_hash;T@�[I" to_s;T@�[I"update;T@�[I"value?;T@�[I"values;T@�[I"values_at;T@�[:protected[ [:private[ [I" instance;T[[;[ [;[ [;[ [ [U:RDoc::Context::Section[i 0o;;[ ;0;0[@�@�cRDoc::TopLevel