Class: String

Inherits:
Object
  • Object
show all
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

Instance Method Details

#composition_similarity(str) ⇒ Object



100
101
102
# File 'lib/string/matching.rb', line 100

def composition_similarity str
  BBLib.composition_similarity self, str
end

#drop_symbolsObject



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_romanObject



56
57
58
# File 'lib/string/roman.rb', line 56

def from_roman
  BBLib.from_roman self
end

#from_roman!Object



60
61
62
# File 'lib/string/roman.rb', line 60

def from_roman!
  replace self.from_roman
end

#levenshtein_distance(str) ⇒ Object



92
93
94
# File 'lib/string/matching.rb', line 92

def levenshtein_distance str
  BBLib.levenshtein_distance self, str
end

#levenshtein_similarity(str) ⇒ Object



96
97
98
# File 'lib/string/matching.rb', line 96

def levenshtein_similarity str
  BBLib.levenshtein_similarity self, str
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) ⇒ Object



108
109
110
# File 'lib/string/matching.rb', line 108

def numeric_similarity str
  BBLib.numeric_similarity self, str
end

#parse_duration(output: :sec) ⇒ Object



75
76
77
# File 'lib/time/bbtime.rb', line 75

def parse_duration output: :sec
  BBLib.parse_duration self, output:output
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) ⇒ Object



104
105
106
# File 'lib/string/matching.rb', line 104

def phrase_similarity str
  BBLib.phrase_similarity self, str
end

#qwerty_distance(str) ⇒ Object



112
113
114
# File 'lib/string/matching.rb', line 112

def qwerty_distance str
  BBLib.qwerty_distance 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_romanObject



64
65
66
# File 'lib/string/roman.rb', line 64

def to_roman
  BBLib.string_to_roman self
end

#to_roman!Object



68
69
70
# File 'lib/string/roman.rb', line 68

def to_roman!
  replace self.to_roman
end