Class: String

Inherits:
Object show all
Defined in:
lib/core_extensions/string.rb

Constant Summary collapse

TITLE_WORDS_NOT_CAPITALIZED =
%W(a an in the for and nor but or yet so also)

Instance Method Summary collapse

Instance Method Details

#epf_backhashed_filenameObject

TODO: Need comprehensive list of characters to be protected.



12
13
14
# File 'lib/core_extensions/string.rb', line 12

def epf_backhashed_filename
  self.gsub(" ", "\\ ")  
end

#epf_blank?Boolean



3
4
5
# File 'lib/core_extensions/string.rb', line 3

def epf_blank?
  self.strip.length == 0  
end

#epf_camelizeObject



7
8
9
# File 'lib/core_extensions/string.rb', line 7

def epf_camelize
  gsub(/(?:^|_)(.)/) { $1.upcase }
end

#epf_deunderscorize_as_titleObject



28
29
30
31
32
33
34
35
36
# File 'lib/core_extensions/string.rb', line 28

def epf_deunderscorize_as_title
  words = self.split("_")
  
  words = [words[0].capitalize] + words[1..-1].map{|w| 
    TITLE_WORDS_NOT_CAPITALIZED.include?(w) ? w : w.capitalize
  }
  
  words.join(" ")
end

#epf_underscorizeObject



16
17
18
# File 'lib/core_extensions/string.rb', line 16

def epf_underscorize
  self.downcase.gsub(/\s+/,"_").gsub(/[\W]/,"")
end

#to_pathnameObject

def fwf_filepath

EpubForge::FunWith::Files::FilePath.new(self)

end



24
25
26
# File 'lib/core_extensions/string.rb', line 24

def to_pathname
  Pathname.new( self )
end