class String
quote
textarea
region
ext
ep
Public Instance Methods
dquote()
click to toggle source
This function is different from dump.
# File lib/el4r/el4r-sub.rb, line 284 def dquote quote('"') end
ep()
click to toggle source
Expand tilde
# File lib/el4r/el4r-sub.rb, line 692 def ep case self when /^~/ File.expand_path(self) else self end end
ext(newext=nil)
click to toggle source
Returns a string which is replaced the filename's extension with NEWEXT.
# File lib/el4r/el4r-sub.rb, line 613 def ext(newext=nil) if newext newext[0,1] != '.' and newext="."+newext sub(/\.[^\.]+?$/, newext) else File.extname(self) end end
kill_region!(regexp)
click to toggle source
Scans a regexp once. Then cut matched part from string. Returns the matched part.
# File lib/el4r/el4r-sub.rb, line 600 def kill_region!(regexp) ret = "" sub!(regexp) { ret = $& "" } ret end
noext()
click to toggle source
Returns a string which is stripped the filename's extension.
# File lib/el4r/el4r-sub.rb, line 623 def noext sub(/\.[^\.]+$/,'') end
quote(q="'")
click to toggle source
# File lib/el4r/el4r-sub.rb, line 279 def quote(q="'") %Q[#{q}#{self}#{q}] end
textarea_ize(cols=nil, rows=nil, escape=true)
click to toggle source
Makes a string textarea-ize. COLS is adjusted to terminal by default. String
is HTML escaped when ESCAPE is true.
# File lib/el4r/el4r-sub.rb, line 496 def textarea_ize(cols=nil, rows=nil, escape=true) cols ||= textarea_default_cols rows = self.split(/\r?\n/).inject(0){|result, item| result + (item.length/cols+1)}+1 unless rows content = if escape require 'fastesc' self.html_escape else self end "<textarea rows=#{rows} cols=#{cols}>#{content}</textarea>" end
textarea_ize_noconv(cols=nil, rows=nil)
click to toggle source
Same as textarea_ize. But the string is not escaped. It is expected that the string is HTML.
# File lib/el4r/el4r-sub.rb, line 510 def textarea_ize_noconv(cols=nil, rows=nil) textarea_ize(cols, rows, false) end
Private Instance Methods
textarea_default_cols()
click to toggle source
# File lib/el4r/el4r-sub.rb, line 482 def textarea_default_cols begin require 'curses' Curses.init_screen Curses.stdscr.maxx-3 ensure Curses.close_screen end end