Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/filebase.rb,
lib/extentions/string.rb
Instance Method Summary collapse
- #as_ext ⇒ Object
- #as_file ⇒ Object
- #as_file_title ⇒ Object
- #as_folder ⇒ Object
- #as_symbol ⇒ Object
- #flag? ⇒ Boolean
- #shift ⇒ Object
Instance Method Details
#as_ext ⇒ Object
6 |
# File 'lib/filebase.rb', line 6 def as_ext; self[0,0]='.' unless self[0,1]=='.'|| self==''; self end |
#as_file ⇒ Object
4 |
# File 'lib/filebase.rb', line 4 def as_file; self.gsub(/([!?,]|[^a-zA-Z0-9]$)/, '').gsub(/[^a-zA-Z0-9\/\.]/, '_').downcase end |
#as_file_title ⇒ Object
7 |
# File 'lib/filebase.rb', line 7 def as_file_title; self.as_file.gsub /_/, ' ' end |
#as_folder ⇒ Object
5 |
# File 'lib/filebase.rb', line 5 def as_folder; (self=~/^[\. \/]{1,2}$/ ? './' : (self.as_file+((self.as_file=~/\/$/||self=='') ? '' : '/'))) end |
#as_symbol ⇒ Object
8 |
# File 'lib/filebase.rb', line 8 def as_symbol; self.as_file.to_sym end |
#flag? ⇒ Boolean
2 |
# File 'lib/extentions/string.rb', line 2 def flag?; self[0,1]=='-' end |
#shift ⇒ Object
3 |
# File 'lib/extentions/string.rb', line 3 def shift; self.slice! 0,1 end |