Sha256: 9b467c28be4abb78e4313580cd152ce7764b8a08ac7c21d06b96a5878f4cfa7c

Contents?: true

Size: 1.05 KB

Versions: 2

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

module Librollenspielsache
  module Dice
    # A single roll
    class Roll < FFI::AutoPointer
      class << self
        def release(ptr)
          Binding.free ptr
        end

        def from_str(str)
          Binding.from_str str
        end
      end

      def execute
        Binding.execute self
      end

      def base
        Binding.get_base self
      end

      def repeat
        Binding.get_repeat self
      end

      # Rust exported fns
      module Binding
        extend FFI::Library
        ffi_lib 'librollenspielsache'

        # Builds a new Roll from a string
        attach_function :from_str, :roll_from_str, [:string], Roll
        # Free the object
        attach_function :free, :roll_free, [], :void
        # Returns a pointer to RollResult
        attach_function :execute, :roll_execute, [Roll], :pointer
        # Get the base
        attach_function :get_base, :roll_base, [Roll], :int
        # Get the repeat
        attach_function :get_repeat, :roll_repeat, [Roll], :uint
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
librollenspielsache-rb-0.1.0 lib/librollenspielsache/dice/roll.rb
librollenspielsache-rb-0.0.1 lib/librollenspielsache/dice/roll.rb