Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/file/bbfile.rb,
lib/time/bbtime.rb,
lib/string/roman.rb,
lib/string/bbstring.rb,
lib/string/matching.rb
Instance Method Summary collapse
- #composition_similarity(str, case_sensitive = false) ⇒ Object
- #drop_symbols ⇒ Object
- #drop_symbols! ⇒ Object
- #extract_integers(convert: true) ⇒ Object
- #extract_numbers(convert: true) ⇒ Object
- #file_name(with_extension = true) ⇒ Object
- #from_roman ⇒ Object
- #from_roman! ⇒ Object
- #levenshtein_distance(str, case_sensitive = false) ⇒ Object
- #levenshtein_similarity(str, case_sensitive = false) ⇒ Object
- #move_articles(position, capitalize = true) ⇒ Object
- #move_articles!(position, capitalize = true) ⇒ Object
-
#msplit(delims, keep_empty: false) ⇒ Object
Multi-split.
- #numeric_similarity(str, case_sensitive = false) ⇒ Object
- #parse_duration(to = :sec) ⇒ Object
- #parse_file_size(output: :byte) ⇒ Object
- #phrase_similarity(str, case_sensitive = false) ⇒ Object
- #qwerty_similarity(str) ⇒ Object
- #to_file(path, mkpath = true) ⇒ Object
- #to_roman ⇒ Object
- #to_roman! ⇒ Object
Instance Method Details
#composition_similarity(str, case_sensitive = false) ⇒ Object
104 105 106 |
# File 'lib/string/matching.rb', line 104 def composition_similarity str, case_sensitive = false BBLib.composition_similarity self, str, case_sensitive end |
#drop_symbols ⇒ Object
82 83 84 |
# File 'lib/string/bbstring.rb', line 82 def drop_symbols BBLib.drop_symbols self end |
#drop_symbols! ⇒ Object
86 87 88 |
# File 'lib/string/bbstring.rb', line 86 def drop_symbols! replace BBLib.drop_symbols(self) end |
#extract_integers(convert: true) ⇒ Object
90 91 92 |
# File 'lib/string/bbstring.rb', line 90 def extract_integers convert: true BBLib.extract_integers self, convert:convert end |
#extract_numbers(convert: true) ⇒ Object
94 95 96 |
# File 'lib/string/bbstring.rb', line 94 def extract_numbers convert: true BBLib.extract_numbers self, convert:convert end |
#file_name(with_extension = true) ⇒ Object
71 72 73 |
# File 'lib/file/bbfile.rb', line 71 def file_name with_extension = true self[(self.include?('/') ? self.rindex('/').to_i+1 : 0)..(with_extension ? -1 : self.rindex('.').to_i-1)] end |
#from_roman ⇒ Object
55 56 57 |
# File 'lib/string/roman.rb', line 55 def from_roman BBLib.from_roman self end |
#from_roman! ⇒ Object
59 60 61 |
# File 'lib/string/roman.rb', line 59 def from_roman! replace self.from_roman end |
#levenshtein_distance(str, case_sensitive = false) ⇒ Object
96 97 98 |
# File 'lib/string/matching.rb', line 96 def levenshtein_distance str, case_sensitive = false BBLib.levenshtein_distance self, str, case_sensitive end |
#levenshtein_similarity(str, case_sensitive = false) ⇒ Object
100 101 102 |
# File 'lib/string/matching.rb', line 100 def levenshtein_similarity str, case_sensitive = false BBLib.levenshtein_similarity self, str, case_sensitive end |
#move_articles(position, capitalize = true) ⇒ Object
74 75 76 |
# File 'lib/string/bbstring.rb', line 74 def move_articles position, capitalize = true BBLib.move_articles self, position, capitalize end |
#move_articles!(position, capitalize = true) ⇒ Object
78 79 80 |
# File 'lib/string/bbstring.rb', line 78 def move_articles! position, capitalize = true replace BBLib.move_articles(self, position, capitalize) end |
#msplit(delims, keep_empty: false) ⇒ Object
Multi-split. Similar to split, but can be passed an array of delimiters to split on.
64 65 66 67 68 69 70 71 72 |
# File 'lib/string/bbstring.rb', line 64 def msplit delims, keep_empty: false return [self] unless !delims.nil? && !delims.empty? ar = [self] delims.each do |d| ar.map!{ |a| a.split d } ar.flatten! end keep_empty ? ar : ar.reject{ |l| l.empty? } end |
#numeric_similarity(str, case_sensitive = false) ⇒ Object
112 113 114 |
# File 'lib/string/matching.rb', line 112 def numeric_similarity str, case_sensitive = false BBLib.numeric_similarity self, str, case_sensitive end |
#parse_duration(to = :sec) ⇒ Object
75 76 77 |
# File 'lib/time/bbtime.rb', line 75 def parse_duration to = :sec BBLib.parse_duration self, to end |
#parse_file_size(output: :byte) ⇒ Object
75 76 77 |
# File 'lib/file/bbfile.rb', line 75 def parse_file_size output: :byte BBLib.parse_file_size(self, output:output) end |
#phrase_similarity(str, case_sensitive = false) ⇒ Object
108 109 110 |
# File 'lib/string/matching.rb', line 108 def phrase_similarity str, case_sensitive = false BBLib.phrase_similarity self, str, case_sensitive end |
#qwerty_similarity(str) ⇒ Object
116 117 118 |
# File 'lib/string/matching.rb', line 116 def qwerty_similarity str BBLib.qwerty_similarity self, str end |
#to_file(path, mkpath = true) ⇒ Object
67 68 69 |
# File 'lib/file/bbfile.rb', line 67 def to_file path, mkpath = true BBLib.string_to_file path, self, mkpath end |
#to_roman ⇒ Object
63 64 65 |
# File 'lib/string/roman.rb', line 63 def to_roman BBLib.string_to_roman self end |
#to_roman! ⇒ Object
67 68 69 |
# File 'lib/string/roman.rb', line 67 def to_roman! replace self.to_roman end |