Construct a new class given a C:
class klass
(CUnion
, CStruct
, or other that provide an entity_class)
types
(Fiddle::TYPE_INT, Fiddle::TYPE_SIZE_T, etc., see the C types constants)
corresponding members
Fiddle::Importer#struct
and Fiddle::Importer#union
wrap this functionality in an easy-to-use manner.
Example:
require 'fiddle/struct' require 'fiddle/cparser' include Fiddle::CParser types, members = parse_struct_signature(['int i','char c']) MyStruct = Fiddle::CStructBuilder.create(Fiddle::CUnion, types, members) obj = MyStruct.allocate
Construct a new class given a C:
class klass
(CUnion
, CStruct
, or other that provide an entity_class)
types
(Fiddle::TYPE_INT, Fiddle::TYPE_SIZE_T, etc., see the C types constants)
corresponding members
Fiddle::Importer#struct
and Fiddle::Importer#union
wrap this functionality in an easy-to-use manner.
Example:
require 'fiddle/struct' require 'fiddle/cparser' include Fiddle::CParser types, members = parse_struct_signature(['int i','char c']) MyStruct = Fiddle::CStructBuilder.create(Fiddle::CUnion, types, members) obj = MyStruct.allocate
Similar to read, but raises EOFError
at end of string instead of returning nil
, as well as IO#sysread
does.
Similar to read, but raises EOFError
at end of string instead of returning nil
, as well as IO#sysread
does.
Reads size
bytes from the stream. If buf
is provided it must reference a string which will receive the data.
See IO#read
for full details.
Reads at most maxlen
bytes from the stream. If buf
is provided it must reference a string which will receive the data.
See IO#readpartial
for full details.
Reads a line from the stream which is separated by eol
.
Raises EOFError
if at end of file.
Reads a one-character string from the stream. Raises an EOFError
at end of file.
Reads a DER or PEM encoded string from string
or io
and returns an instance of the appropriate PKey
class.
string
is a DER- or PEM-encoded string containing an arbitrary private or public key.
io
is an instance of IO
containing a DER- or PEM-encoded arbitrary private or public key.
pwd
is an optional password in case string
or file
is an encrypted PEM resource.
Return true if the PRNG has been seeded with enough data, false otherwise.
Start streaming using encoding
Returns a profile data report such as:
GC 1 invokes. Index Invoke Time(sec) Use Size(byte) Total Size(byte) Total Object GC time(ms) 1 0.012 159240 212940 10647 0.00000000000001530000
Prettify (indent) an HTML string.
string
is the HTML string to indent. shift
is the indentation unit to use; it defaults to two spaces.
print CGI::pretty("<HTML><BODY></BODY></HTML>") # <HTML> # <BODY> # </BODY> # </HTML> print CGI::pretty("<HTML><BODY></BODY></HTML>", "\t") # <HTML> # <BODY> # </BODY> # </HTML>
Generate a Form element as a string.
method
should be either “get” or “post”, and defaults to the latter. action
defaults to the current CGI
script name. enctype
defaults to “application/x-www-form-urlencoded”.
Alternatively, the attributes can be specified as a hash.
See also multipart_form()
for forms that include file uploads.
form{ "string" } # <FORM METHOD="post" ENCTYPE="application/x-www-form-urlencoded">string</FORM> form("get") { "string" } # <FORM METHOD="get" ENCTYPE="application/x-www-form-urlencoded">string</FORM> form("get", "url") { "string" } # <FORM METHOD="get" ACTION="url" ENCTYPE="application/x-www-form-urlencoded">string</FORM> form("METHOD" => "post", "ENCTYPE" => "enctype") { "string" } # <FORM METHOD="post" ENCTYPE="enctype">string</FORM>
Generate a reset button Input element, as a String.
This resets the values on a form to their initial values. value
is the text displayed on the button. name
is the name of this button.
Alternatively, the attributes can be specified as a hash.
reset # <INPUT TYPE="reset"> reset("reset") # <INPUT TYPE="reset" VALUE="reset"> reset("VALUE" => "reset", "ID" => "foo") # <INPUT TYPE="reset" VALUE="reset" ID="foo">
Generate a TextArea element, as a String.
name
is the name of the textarea. cols
is the number of columns and rows
is the number of rows in the display.
Alternatively, the attributes can be specified as a hash.
The body is provided by the passed-in no-argument block
textarea("name") # = textarea("NAME" => "name", "COLS" => 70, "ROWS" => 10) textarea("name", 40, 5) # = textarea("NAME" => "name", "COLS" => 40, "ROWS" => 5)
OpenURI::OpenRead#read([options]
) reads a content referenced by self and returns the content as string. The string is extended with OpenURI::Meta
. The argument options
is same as OpenURI::OpenRead#open
.
Parses self
destructively in order and returns self
containing the rest arguments left unparsed.
Substitution of getopts is possible as follows. Also see OptionParser#getopts
.
def getopts(*args) ($OPT = ARGV.getopts(*args)).each do |opt, val| eval "$OPT_#{opt.gsub(/[^A-Za-z0-9_]/, '_')} = val" end rescue OptionParser::ParseError end
Adds a separated list. The list is separated by comma with breakable space, by default.
seplist
iterates the list
using iter_method
. It yields each object to the block given for seplist
. The procedure separator_proc
is called between each yields.
If the iteration is zero times, separator_proc
is not called at all.
If separator_proc
is nil or not given, +lambda { comma_breakable
}+ is used. If iter_method
is not given, :each is used.
For example, following 3 code fragments has similar effect.
q.seplist([1,2,3]) {|v| xxx v } q.seplist([1,2,3], lambda { q.comma_breakable }, :each) {|v| xxx v } xxx 1 q.comma_breakable xxx 2 q.comma_breakable xxx 3