Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_ext/string.rb

Overview

extending String with #parameterized? and #balanced_parens? only to assist macro.rb

Instance Method Summary collapse

Instance Method Details

#balanced_parens?Boolean

returns whether number of open parentheses and close parentheses match

Returns:

  • (Boolean)


12
13
14
# File 'lib/ruby_ext/string.rb', line 12

def balanced_parens?
  self.match(/\(/).size == self.match(/\)/).size
end

#parameterized?Boolean

returns whether or not contents include any Macro strings i.e. Parameter expressions

Returns:

  • (Boolean)


7
8
9
# File 'lib/ruby_ext/string.rb', line 7

def parameterized?
  self.include?('@(')
end