Executes the given block within the context of the receiver (obj). In order to set the context, the variable self
is set to obj while the code is executing, giving the code access to obj’s instance variables. Arguments are passed as block parameters.
class KlassWithSecret def initialize @secret = 99 end end k = KlassWithSecret.new k.instance_exec(5) {|x| @secret+x } #=> 104
This method is a shortcut for converting a single row (Array) into a CSV
String.
The options
parameter can be anything CSV::new()
understands. This method understands an additional :encoding
parameter to set the base Encoding
for the output. This method will try to guess your Encoding
from the first non-nil
field in row
, if possible, but you may need to use this parameter as a backup plan.
The :row_sep
option
defaults to $INPUT_RECORD_SEPARATOR
($/
) when calling this method.
This method is a shortcut for converting a single line of a CSV
String into an Array. Note that if line
contains multiple rows, anything beyond the first row is ignored.
The options
parameter can be anything CSV::new()
understands.
Stores the indicated separators for later use.
If auto-discovery was requested for @row_sep
, this method will read ahead in the @io
and try to find one. ARGF
, STDIN
, STDOUT
, STDERR
and any stream open for output only with a default @row_sep
of $INPUT_RECORD_SEPARATOR
($/
).
This method also establishes the quoting rules used for CSV
output.
Pre-compiles parsers and stores them by name for access during reads.
Loads any converters requested during construction.
If field_name
is set :converters
(the default) field converters are set. When field_name
is :header_converters
header converters are added instead.
The :unconverted_fields
option is also activated for :converters
calls, if requested.
Stores header row settings and loads header converters, if needed.
Stores the pattern of comments to skip from the provided options.
The pattern must respond to .match
, else ArgumentError
is raised. Strings are converted to a Regexp
.
See also CSV.new
Returns the encoding of the internal IO
object or the default
if the encoding cannot be determined.
Returns the list of break points where execution will be stopped.
See DEBUGGER__
for more usage
Serialization support for the object returned by _getobj_.
Reinitializes delegation from a serialized object.
Creates a new compiler for ERB
. See ERB::Compiler.new for details
Returns a string containing the IP address representation in canonical form.
Returns true if the ipaddr is an IPv4-mapped IPv6 address.
Returns a new ipaddr built by converting the native IPv4 address into an IPv4-mapped IPv6 address.
Returns a string for DNS reverse lookup compatible with RFC1886.
Set
date-time format.
datetime_format
A string suitable for passing to strftime
.
Returns the date format being used. See datetime_format=