Class: String

Inherits:
Object show all
Defined in:
lib/stratagem/extensions/string.rb

Instance Method Summary collapse

Instance Method Details

#stratagem_contains_token?(token) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/stratagem/extensions/string.rb', line 6

def stratagem_contains_token?(token)
  match = false
  [
    Regexp.compile("^#{token}$", true),
    Regexp.compile("^#{token}[^A-Za-z0-9_\-]*", true),
    Regexp.compile("[^A-Za-z0-9_\-]*#{token}$", true),
  ].each do |regex|
    if (regex.match(self))
      match = true
      break
    end
  end
  match
end

#stratagem_strip_erbObject



2
3
4
# File 'lib/stratagem/extensions/string.rb', line 2

def stratagem_strip_erb
  self.gsub(/^[<%=]+/, '').gsub(/[-%>]+$/,'').strip
end