artichoke_backend/extn/core/numeric/
mruby.rs

1use std::ffi::CStr;
2
3use crate::extn::core::numeric::Numeric;
4use crate::extn::prelude::*;
5
6const NUMERIC_CSTR: &CStr = c"Numeric";
7static NUMERIC_RUBY_SOURCE: &[u8] = include_bytes!("numeric.rb");
8
9pub fn init(interp: &mut Artichoke) -> InitializeResult<()> {
10    if interp.is_class_defined::<Numeric>() {
11        return Ok(());
12    }
13    let spec = class::Spec::new("Numeric", NUMERIC_CSTR, None, None)?;
14    interp.def_class::<Numeric>(spec)?;
15    interp.eval(NUMERIC_RUBY_SOURCE)?;
16    Ok(())
17}