class String
Public Instance Methods
classify()
click to toggle source
# File lib/core_ext.rb, line 38 def classify sub(/^[a-z\d]*/, &:capitalize).gsub(%r{(?:_|(\/))([a-z\d]*)}i) do "#{Regexp.last_match(1)}#{Regexp.last_match(2).capitalize}" end.gsub('/', '::') end
satisfies_requirement?(requirement_string)
click to toggle source
# File lib/core_ext.rb, line 44 def satisfies_requirement?(requirement_string) version = Gem::Version.new(self) requirement = Gem::Requirement.new(requirement_string) requirement.satisfied_by?(version) end
underscore()
click to toggle source
:reek: TooManyStatements
# File lib/core_ext.rb, line 30 def underscore return self unless self =~ /[A-Z-]|::/ word = to_s.gsub('::', '/') word.gsub!(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2') word.gsub!(/([a-z\d])([A-Z])/, '\1_\2') word.tr('-', '_').downcase end
which()
click to toggle source
# File lib/core_ext.rb, line 21 def which bin_path = ENV['PATH'].split(File::PATH_SEPARATOR).find do |path| file = File.join(path, self) File.exist?(file) && File.executable?(file) end bin_path ? File.join(bin_path, self) : nil end