Equivalent to ENV#keep_if but returns nil
if no changes were made.
Returns a new hash created by using environment variable names as values and values as names.
Returns true when there are no environment variables
Returns true
if there is an environment variable with the given name
.
Synonym for $stdin.
This method is an alias for http_header
, when HTML5
tag maker is inactive.
NOTE: use http_header
to create HTTP header blocks, this alias is only provided for backwards compatibility.
Using header
with the HTML5
tag maker will create a <header> element.
This method is a convenience for building Unix-like filters for CSV
data. Each row is yielded to the provided block which can alter it as needed. After the block returns, the row is appended to output
altered or not.
The input
and output
arguments can be anything CSV::new()
accepts (generally String or IO
objects). If not given, they default to ARGF
and $stdout
.
The options
parameter is also filtered down to CSV::new()
after some clever key parsing. Any key beginning with :in_
or :input_
will have that leading identifier stripped and will only be used in the options
Hash
for the input
object. Keys starting with :out_
or :output_
affect only output
. All other keys are assigned to both objects.
The :output_row_sep
option
defaults to $INPUT_RECORD_SEPARATOR
($/
).
This method wraps a String you provide, or an empty default String, in a CSV
object which is passed to the provided block. You can use the block to append CSV
rows to the String and when the block exits, the final String will be returned.
Note that a passed String is modified by this method. Call dup() before passing if you need a new String.
The options
parameter can be anything CSV::new()
understands. This method understands an additional :encoding
parameter when not passed a String to set the base Encoding
for the output. CSV
needs this hint if you plan to output non-ASCII compatible data.
This method opens an IO
object, and wraps that with CSV
. This is intended as the primary interface for writing a CSV
file.
You must pass a filename
and may optionally add a mode
for Ruby’s open(). You may also pass an optional Hash
containing any options
CSV::new()
understands as the final argument.
This method works like Ruby’s open() call, in that it will pass a CSV
object to a provided block and close it when the block terminates, or it will return the CSV
object when no block is provided. (Note: This is different from the Ruby 1.8 CSV
library which passed rows to the block. Use CSV::foreach()
for that behavior.)
You must provide a mode
with an embedded Encoding
designator unless your data is in Encoding::default_external()
. CSV
will check the Encoding
of the underlying IO
object (set by the mode
you pass) to determine how to parse the data. You may provide a second Encoding
to have the data transcoded as it is read just as you can with a normal call to IO::open()
. For example, "rb:UTF-32BE:UTF-8"
would read UTF-32BE data from the file but transcode it to UTF-8 before CSV
parses it.
An opened CSV
object will delegate to many IO
methods for convenience. You may call:
binmode()
binmode?()
close()
close_read()
close_write()
closed?()
eof()
eof?()
external_encoding()
fcntl()
fileno()
flock()
flush()
fsync()
internal_encoding()
ioctl()
isatty()
path()
pid()
pos()
pos=()
reopen()
seek()
stat()
sync()
sync=()
tell()
to_i()
to_io()
truncate()
tty?()
Start tracing
Tracer.on # code to trace here Tracer.off
You can also pass a block:
Tracer.on { # trace everything in this block }
Returns the list of waiting threads.
When stepping through the traces of a function, thread gets suspended, to be resumed later.
Use __raise__ if your Delegator
does not have a object to delegate the raise method call.
This method must be overridden by subclasses and change the object delegate to obj.
Changes the delegate object to obj.
It’s important to note that this does not cause SimpleDelegator’s methods to change. Because of this, you probably only want to change delegation to objects of the same type as the original delegate.
Here’s an example of changing the delegation object.
names = SimpleDelegator.new(%w{James Edward Gray II}) puts names[1] # => Edward names.__setobj__(%w{Gavin Sinclair}) puts names[1] # => Sinclair
Set
the handling of the ordering of options and arguments. A RuntimeError
is raised if option processing has already started.
The supplied value must be a member of GetoptLong::ORDERINGS
. It alters the processing of options as follows:
REQUIRE_ORDER :
Options are required to occur before non-options.
Processing of options ends as soon as a word is encountered that has not been preceded by an appropriate option flag.
For example, if -a and -b are options which do not take arguments, parsing command line arguments of ‘-a one -b two’ would result in ‘one’, ‘-b’, ‘two’ being left in ARGV, and only (‘-a’, ”) being processed as an option/arg pair.
This is the default ordering, if the environment variable POSIXLY_CORRECT is set. (This is for compatibility with GNU getopt_long.)
PERMUTE :
Options can occur anywhere in the command line parsed. This is the default behavior.
Every sequence of words which can be interpreted as an option (with or without argument) is treated as an option; non-option words are skipped.
For example, if -a does not require an argument and -b optionally takes an argument, parsing ‘-a one -b two three’ would result in (‘-a’,”) and (‘-b’, ‘two’) being processed as option/arg pairs, and ‘one’,‘three’ being left in ARGV.
If the ordering is set to PERMUTE but the environment variable POSIXLY_CORRECT is set, REQUIRE_ORDER is used instead. This is for compatibility with GNU getopt_long.
RETURN_IN_ORDER :
All words on the command line are processed as options. Words not preceded by a short or long option flag are passed as arguments with an option of ” (empty string).
For example, if -a requires an argument but -b does not, a command line of ‘-a one -b two three’ would result in option/arg pairs of (‘-a’, ‘one’) (‘-b’, ”), (”, ‘two’), (”, ‘three’) being processed.
Explicitly terminate option processing.
Returns true if option processing has terminated, false otherwise.
Convert a network byte ordered string form of an IP address into human readable form.
Returns a network byte ordered string form of the IP address.
Returns a new ipaddr built by converting the IPv6 address into a native IPv4 address. If the IP address is not an IPv4-mapped or IPv4-compatible IPv6 address, returns self.
Set
+@addr+, the internal stored ip address, to given addr
. The parameter addr
is validated using the first family
member, which is Socket::AF_INET
or Socket::AF_INET6
.
Returns true
iff the current severity level allows for the printing of WARN
messages.
Returns true
iff the current severity level allows for the printing of ERROR
messages.