Closes self
for writing; closed-read setting remains unchanged.
Raises IOError
if writing is attempted.
Related: StringIO#close
, StringIO#close_read
.
Returns true
if self
is closed for reading, false
otherwise.
Returns true
if self
is closed for writing, false
otherwise.
Returns the Encoding
object that represents the encoding of the file. If the stream is write mode and no encoding is specified, returns nil
.
Returns the Encoding
of the internal string if conversion is specified. Otherwise returns nil
.
This method is defined for backward compatibility.
Scans one byte and returns it. This method is not multibyte character sensitive. See also: getch
.
s = StringScanner.new('ab') s.get_byte # => "a" s.get_byte # => "b" s.get_byte # => nil s = StringScanner.new("\244\242".force_encoding("euc-jp")) s.get_byte # => "\xA4" s.get_byte # => "\xA2" s.get_byte # => nil
Defines the constants of OLE Automation server as mod’s constants. The first argument is WIN32OLE
object or type library name. If 2nd argument is omitted, the default is WIN32OLE
. The first letter of Ruby’s constant variable name is upper case, so constant variable name of WIN32OLE
object is capitalized. For example, the ‘xlTop’ constant of Excel is changed to ‘XlTop’ in WIN32OLE
. If the first letter of constant variable is not [A-Z], then the constant is defined as CONSTANTS hash element.
module EXCEL_CONST end excel = WIN32OLE.new('Excel.Application') WIN32OLE.const_load(excel, EXCEL_CONST) puts EXCEL_CONST::XlTop # => -4160 puts EXCEL_CONST::CONSTANTS['_xlDialogChartSourceData'] # => 541 WIN32OLE.const_load(excel) puts WIN32OLE::XlTop # => -4160 module MSO end WIN32OLE.const_load('Microsoft Office 9.0 Object Library', MSO) puts MSO::MsoLineSingle # => 1
If obj
is a Hash object, returns obj
.
Otherwise if obj
responds to :to_hash
, calls obj.to_hash
and returns the result.
Returns nil
if obj
does not respond to :to_hash
Raises an exception unless obj.to_hash
returns a Hash object.
Reads at most maxlen bytes from the ARGF
stream in non-blocking mode.
Returns the external encoding for files read from ARGF
as an Encoding
object. The external encoding is the encoding of the text as stored in a file. Contrast with ARGF.internal_encoding
, which is the encoding used to represent this text within Ruby.
To set the external encoding use ARGF.set_encoding
.
For example:
ARGF.external_encoding #=> #<Encoding:UTF-8>
Returns the internal encoding for strings read from ARGF
as an Encoding
object.
If ARGF.set_encoding
has been called with two encoding names, the second is returned. Otherwise, if Encoding.default_external
has been set, that value is returned. Failing that, if a default external encoding was specified on the command-line, that value is used. If the encoding is unknown, nil
is returned.
Returns the value that determines whether unconverted fields are to be available; used for parsing; see {Option unconverted_fields
}:
CSV.new('').unconverted_fields? # => nil
Returns the value that determines whether headers are to be returned; used for parsing; see {Option return_headers
}:
CSV.new('').return_headers? # => false
Returns the value that determines whether headers are to be written; used for generating; see {Option write_headers
}:
CSV.new('').write_headers? # => nil
Returns the value that determines whether illegal input is to be handled; used for parsing; see {Option liberal_parsing
}:
CSV.new('').liberal_parsing? # => false
Returns true
if the next row to be read is a header row; false
otherwise.
Without headers:
string = "foo,0\nbar,1\nbaz,2\n" csv = CSV.new(string) csv.header_row? # => false
With headers:
string = "Name,Value\nfoo,0\nbar,1\nbaz,2\n" csv = CSV.new(string, headers: true) csv.header_row? # => true csv.shift # => #<CSV::Row "Name":"foo" "Value":"0"> csv.header_row? # => false
Raises an exception if the source is not opened for reading:
string = "foo,0\nbar,1\nbaz,2\n" csv = CSV.new(string) csv.close # Raises IOError (not opened for reading) csv.header_row?
Processes fields
with @converters
, or @header_converters
if headers
is passed as true
, returning the converted field set. Any converter that changes the field into something other than a String
halts the pipeline of conversion for that field. This is primarily an efficiency shortcut.
Reinitializes delegation from a serialized object.
Allow connections from Socket
soc
?
Allow connections from addrinfo addr
? It must be formatted like Socket#peeraddr:
["AF_INET", 10, "lc630", "192.0.2.1"]