rkh/convinius
Convenience library for Rubinius-only projects.
{ "createdAt": "2011-01-26T11:24:41Z", "defaultBranch": "master", "description": "Convenience library for Rubinius-only projects.", "fullName": "rkh/convinius", "homepage": null, "language": "Ruby", "name": "convinius", "pushedAt": "2011-02-03T23:57:05Z", "stargazersCount": 17, "topics": [], "updatedAt": "2023-11-30T02:16:14Z", "url": "https://github.com/rkh/convinius"}Convinius
Section titled “Convinius”Convenience library for Rubinius-only projects.
Use require 'convinius' to get all features.
Installation:
gem install conviniusRunning tests:
gem install rspecrspec specSubclassing from arbitrary Objects
Section titled “Subclassing from arbitrary Objects”in: convinius/to_class
If you subclass from an object, first call to_class on that object and
subclass the result instead:
RandomClass = Object.new
def RandomClass.to_class [Hash, Object, Set].at rand(3)end
class Foo < RandomClass puts superclassendA more realistic example:
module Awesome def self.to_class Class.new { include Awesome } endend
class Foo < Awesomeend
class Bar < Something include AwesomeendCreating own subclass of Class
Section titled “Creating own subclass of Class”in: convinius/subclass_class
class MyClass < Classend
Foo = MyClass.new BarFoo.new.class # => FooFoo.class # => MyClass (without patch this would be Class)Import constants from Rubinius
Section titled “Import constants from Rubinius”in: convinius/globals
Defines global constants Tuple and Fiber.
Convenience for Rubinius::Generator
Section titled “Convenience for Rubinius::Generator”in: convinius/generator
Method for generating tuples (like make_array):
class MyNode < Rubinius::AST::Node def bytecode(g) (1..5).each { |i| g.push i } g.make_tuple 5 endendByte Code Generator DSL
Section titled “Byte Code Generator DSL”in: convinius/asm
Example:
include Convinius::ASM
compiled = asm do push 1 push 2 send :+, 1end
p compiled.callIf block takes an argument, it won’t use instance_eval:
Convinius::ASM.new do |g| g.push 1 g.push 2 g.send :+, 1end