1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use std::ffi::CStr;

use crate::extn::core::numeric::Numeric;
use crate::extn::prelude::*;

const NUMERIC_CSTR: &CStr = qed::const_cstr_from_str!("Numeric\0");
static NUMERIC_RUBY_SOURCE: &[u8] = include_bytes!("numeric.rb");

pub fn init(interp: &mut Artichoke) -> InitializeResult<()> {
    if interp.is_class_defined::<Numeric>() {
        return Ok(());
    }
    let spec = class::Spec::new("Numeric", NUMERIC_CSTR, None, None)?;
    interp.def_class::<Numeric>(spec)?;
    interp.eval(NUMERIC_RUBY_SOURCE)?;
    Ok(())
}