Module: RubyHeaderParser::Util
- Defined in:
- lib/ruby_header_parser/util.rb
Overview
util methods
Class Method Summary collapse
- .find_field(array, field_name) ⇒ String?
- .sanitize_type(type) ⇒ String
- .split_signature(signature) ⇒ Array<String>
Class Method Details
.find_field(array, field_name) ⇒ String?
9 10 11 12 13 14 15 |
# File 'lib/ruby_header_parser/util.rb', line 9 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 |
.sanitize_type(type) ⇒ String
25 26 27 |
# File 'lib/ruby_header_parser/util.rb', line 25 def self.sanitize_type(type) type.gsub(/(enum|volatile|const|struct|static\s+inline)\s+/i, "").gsub("const*", "").strip end |
.split_signature(signature) ⇒ Array<String>
19 20 21 |
# File 'lib/ruby_header_parser/util.rb', line 19 def self.split_signature(signature) signature.scan(/[^,]+\([^()]*\)|[^,]+/).flatten.map(&:strip) end |