Module: DTRCore::Common

Included in:
Function, Parser, State, TypeValidator
Defined in:
lib/dtr_core/common.rb

Overview

Common methods used by the DTRCore module.

Instance Method Summary collapse

Instance Method Details

#clean_name(definition) ⇒ Object



18
19
20
# File 'lib/dtr_core/common.rb', line 18

def clean_name(definition)
  definition.gsub(/[\*\n\[]/, '').strip
end

#first_match_for_content(patterm) ⇒ Object



14
15
16
# File 'lib/dtr_core/common.rb', line 14

def first_match_for_content(patterm)
  content.match(patterm)&.captures&.first
end

#split_strip_select(some_list) ⇒ Object



10
11
12
# File 'lib/dtr_core/common.rb', line 10

def split_strip_select(some_list)
  some_list&.split("\n")&.map(&:strip)&.select { |x| x.length.positive? }
end

#strip_and_remove_quotes(str) ⇒ Object



6
7
8
# File 'lib/dtr_core/common.rb', line 6

def strip_and_remove_quotes(str)
  str.strip.gsub(/['"]/, '')
end