lib/rnp/misc.rb in rnp-1.0.2 vs lib/rnp/misc.rb in rnp-1.0.3

- old
+ new

@@ -65,7 +65,84 @@ pformat.read_string unless pformat.null? ensure LibRnp.rnp_buffer_destroy(pformat) end end + + # Add ASCII Armor to data. + # + # @param input [Input] the input to read data from + # @param output [Output] the output to write the armored + # data to. If nil, the result will be returned directly + # as a String. + # @return [nil, String] + def self.enarmor(input:, output: nil, type: nil) + Output.default(output) do |output_| + Rnp.call_ffi(:rnp_enarmor, input.ptr, output_.ptr, type) + end + end + + # Remove ASCII Armor from data. + # + # @param input [Input] the input to read the ASCII-Armored data from + # @param output [Output] the output to write the dearmored data to. If + # nil, the result will be returned directly as a String. + # @return [nil, String] + def self.dearmor(input:, output: nil) + Output.default(output) do |output_| + Rnp.call_ffi(:rnp_dearmor, input.ptr, output_.ptr) + end + end + + # Get the version of the rnp library as a string. + # + # @return [String] + def self.version_string + LibRnp.rnp_version_string + end + + # Get the detailed version of the rnp library as a string. + # + # @return [String] + def self.version_string_full + LibRnp.rnp_version_string_full + end + + # Get the version stamp of the rnp library as an unsigned + # 32-bit integer. This number can be compared against other + # stamps generated with {version_for}. + # + # @return [Integer] + def self.version + LibRnp.rnp_version + end + + # Encode the given major, minor, and patch numbers into a version + # stamp. + # + # @return [Integer] + def self.version_for(major, minor, patch) + LibRnp.rnp_version_for(major, minor, patch) + end + + # Extract the major version component from the given version stamp. + # + # @return [Integer] + def self.version_major(version) + LibRnp.rnp_version_major(version) + end + + # Extract the minor version component from the given version stamp. + # + # @return [Integer] + def self.version_minor(version) + LibRnp.rnp_version_minor(version) + end + + # Extract the patch version component from the given version stamp. + # + # @return [Integer] + def self.version_patch(version) + LibRnp.rnp_version_patch(version) + end end # class