lib/procemon/mpatch/string.rb in procemon-0.1.1 vs lib/procemon/mpatch/string.rb in procemon-0.1.3

- old
+ new

@@ -62,12 +62,34 @@ # Check that instance of String is start with an upper case or not def capitalized? self.match(/^[[:upper:]]/) ? true : false end -end + # return the number how often the str is with in the self + # by default with \b regex border + def frequency(str) + begin + if str.class == String + str= '\b'+str+'\b' + end + end + self.scan(/#{str}/).count + end -=begin + # create process object from valid process string + def to_proc(binding=nil) + begin -/\b[A-Z]\w*/ #> this is for find capitalized words + if !self.include?('Proc.new') && !self.include?('lambda') + raise ArgumentError, "string obj is not a valid process source" + end -=end + if binding.nil? + return eval(self) + else + return eval(self,binding) + end + + end + end + +end \ No newline at end of file