Add BSD::Control.library_version

This commit is contained in:
0x1eef 2024-03-01 01:28:54 -03:00
parent c94d705f4d
commit 2db227b0c3
3 changed files with 16 additions and 1 deletions

View file

@ -26,6 +26,14 @@ ffi_available_features(VALUE self)
return features;
}
static VALUE
ffi_library_version(VALUE self)
{
const char *ver;
ver = hbsdcontrol_get_version();
return rb_str_new2(ver);
}
static VALUE
feature_set(VALUE self, VALUE path, VALUE state)
{
@ -65,5 +73,6 @@ Init_hbsdctl(void)
rb_define_const(rb_mControl, "Disable", 0);
rb_define_const(rb_mControl, "Enable", 1);
rb_define_singleton_method(rb_mFFI, "available_features", ffi_available_features, 0);
rb_define_singleton_method(rb_mFFI, "library_version", ffi_library_version, 0);
rb_define_method(rb_cFeature, "set!", feature_set, 2);
}

View file

@ -2,6 +2,13 @@ module BSD::Control
require_relative "control/feature"
Error = Class.new(RuntimeError)
##
# @return [String]
# Returns the version of libhbsdcontrol.
def self.library_version
FFI.library_version
end
##
# @return [Array<BSD::Control::Feature>]
def self.available_features

View file

@ -124,6 +124,5 @@ module BSD::Control
end
# @endgroup
private :set!
end
end