Sha256: 8cf964ece53fa6107688c3eb6d2ed51da04ff15c8db7023c415f28f23a033b03

Contents?: true

Size: 762 Bytes

Versions: 3

Compression:

Stored size: 762 Bytes

Contents

# frozen_string_literal: true

module RubyHeaderParser
  # util methods
  module Util
    # @param array [Array<String>]
    # @param field_name [String]
    # @return [String,nil]
    def self.find_field(array, field_name)
      array.each do |element|
        return element.delete_prefix("#{field_name}:").strip if element.start_with?("#{field_name}:")
      end

      nil
    end

    # @param signature [String]
    # @return [Array<String>]
    def self.split_signature(signature)
      signature.scan(/[^,]+\([^()]*\)|[^,]+/).flatten.map(&:strip)
    end

    # @param type [String]
    # @return [String]
    def self.sanitize_type(type)
      type.gsub(/(enum|volatile|const|struct|static\s+inline)\s+/i, "").gsub("const*", "").strip
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby_header_parser-0.3.0 lib/ruby_header_parser/util.rb
ruby_header_parser-0.2.0 lib/ruby_header_parser/util.rb
ruby_header_parser-0.1.0 lib/ruby_header_parser/util.rb