Class: String
Constant Summary collapse
- TITLE_WORDS_NOT_CAPITALIZED =
%W(a an in the for and nor but or yet so also)
Instance Method Summary collapse
-
#epf_backhashed_filename ⇒ Object
TODO: Need comprehensive list of characters to be protected.
- #epf_blank? ⇒ Boolean
- #epf_camelize ⇒ Object
- #epf_deunderscorize_as_title ⇒ Object
- #epf_underscorize ⇒ Object
-
#to_pathname ⇒ Object
def fwf_filepath EpubForge::FunWith::Files::FilePath.new(self) end.
Instance Method Details
#epf_backhashed_filename ⇒ Object
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_camelize ⇒ Object
7 8 9 |
# File 'lib/core_extensions/string.rb', line 7 def epf_camelize gsub(/(?:^|_)(.)/) { $1.upcase } end |
#epf_deunderscorize_as_title ⇒ Object
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_underscorize ⇒ Object
16 17 18 |
# File 'lib/core_extensions/string.rb', line 16 def epf_underscorize self.downcase.gsub(/\s+/,"_").gsub(/[\W]/,"") end |
#to_pathname ⇒ Object
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 |