module Algerb::Util
Public Instance Methods
file_to_class(file)
click to toggle source
# File lib/algerb/util.rb, line 2 def file_to_class(file) remove_ext(file).split('_').map {|word| word.capitalize }.join('') end
indentation(code, level)
click to toggle source
# File lib/algerb/util.rb, line 6 def indentation(code, level) code.split("\n").map {|line| ' ' * level + line + "\n" }.join('') end
remove_dir(path)
click to toggle source
# File lib/algerb/util.rb, line 10 def remove_dir(path) path.sub(%r{^([a-z0-9\_]*/)*}, '') end
remove_ext(path)
click to toggle source
# File lib/algerb/util.rb, line 14 def remove_ext(path) path.sub(/\.rb$/, '') end
split_dir_and_file(path)
click to toggle source
# File lib/algerb/util.rb, line 18 def split_dir_and_file(path) path.scan(%r{^(?:(.*)/)?([^/]+)$})[0] end
split_path_as_head_and_tail(path)
click to toggle source
# File lib/algerb/util.rb, line 22 def split_path_as_head_and_tail(path) path.split('/', 2) end