Module: Cryolite

Defined in:
lib/cryolite.rb,
lib/cryolite/version.rb

Constant Summary collapse

COMPILED_BY_CRYSTAL =

This is how runing under Crystal can be detected.

(((1 / 2) * 2) != 0)
U8_0 =

An 8-bit zero constant to hint the use of UInt8 instead of Int32 for Crystal

"\0".bytes.first
I64_0 =

A 64-bit zero constant to hint the use of Int64 instead of Int32 for Crystal

(0x3FFFFFFFFFFFFFFF & 0)
I128_0 =

A 128-bit zero constant to hint the use of Int128 instead of Int32 for Crystal

0.to_i128
VERSION =
"0.1.0"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.eval_if_run_by_ruby(src) ⇒ Object



32
# File 'lib/cryolite.rb', line 32

def self.eval_if_run_by_ruby(src) if (k = ::Kernel).responds_to? :eval ; k.eval src end end

.ruby_class_method_alias(classname, from, to) ⇒ Object

A convenient wrapper



37
38
# File 'lib/cryolite.rb', line 37

def self.ruby_class_method_alias(classname, from, to) eval_if_run_by_ruby "class
#{classname} alias_singleton_method :#{to}, :#{from} end" end

Instance Method Details

#tuple2(a, b) ⇒ Object

This is a Ruby-compatible trick to create a Crystal's lightweight tuple



20
# File 'lib/cryolite.rb', line 20

def tuple2(a, b) return a, b end

#tuple3(a, b, c) ⇒ Object



21
# File 'lib/cryolite.rb', line 21

def tuple3(a, b, c) return a, b, c end