Module: StringExtensions

Included in:
String
Defined in:
lib/extensions/string_extensions.rb

Overview

String extensions

Instance Method Summary collapse

Instance Method Details

#similarity(text2) ⇒ Object

This method computes string similarity value and returns a number from 0-1.



10
11
12
# File 'lib/extensions/string_extensions.rb', line 10

def similarity (text2)
  test_case.get_string_similarity(self, text2)
end

#substring_similarity(text2) ⇒ Object

This method computes the substring similarity value and returns a number from 0-1.



5
6
7
# File 'lib/extensions/string_extensions.rb', line 5

def substring_similarity (text2)
  test_case.get_substring_similarity(self, text2)
end

#to_arr(del = ',') ⇒ Object



14
15
16
# File 'lib/extensions/string_extensions.rb', line 14

def to_arr(del=',')
  self.split(del)
end

#to_downcase_str_arr(del = ',') ⇒ Object



22
23
24
# File 'lib/extensions/string_extensions.rb', line 22

def to_downcase_str_arr(del=',')
  self.split(del).collect{|x| x.to_s.downcase}
end

#to_i_arr(del = ',') ⇒ Object



26
27
28
# File 'lib/extensions/string_extensions.rb', line 26

def to_i_arr(del=',')
  self.split(del).collect{|x| x.to_i}
end

#to_str_arr(del = ',') ⇒ Object



18
19
20
# File 'lib/extensions/string_extensions.rb', line 18

def to_str_arr(del=',')
  self.split(del).collect{|x| x.to_s}
end

#to_timeObject

Public: Converts a string to Time. String must be parseable by DateTime.parse.



31
32
33
# File 'lib/extensions/string_extensions.rb', line 31

def to_time
  DateTime.parse(self).to_time
end