class MoreUtils

Public Class Methods

flag_lookup(arr) click to toggle source
# File lib/utils/strings.rb, line 67
def flag_lookup arr
    arr.each_with_object({}) do |e, acc|
        e = e.gsub('--', '')
        key, val = e.split('=')
        acc[key.to_sym] = val
        acc
    end
end
gem_version() click to toggle source
# File lib/utils/strings.rb, line 39
def gem_version
    "0.4.2"
end
get_args(arr) click to toggle source
# File lib/utils/strings.rb, line 63
def get_args arr
    arr.reject { |e| /--/.match(e) }
end
get_file_str(path) click to toggle source
# File lib/utils/strings.rb, line 43
def get_file_str path
    File.open(path, 'r:UTF-8', &:read)
end
get_flags(arr) click to toggle source
# File lib/utils/strings.rb, line 59
def get_flags arr
    arr.select { |e| /--/.match(e) }
end
root() click to toggle source
# File lib/utils/strings.rb, line 55
def root
    Dir.pwd
end
this_dir() click to toggle source
# File lib/utils/strings.rb, line 51
def this_dir
    __dir__
end
versions(lookup) click to toggle source
# File lib/utils/strings.rb, line 23
def versions lookup
    version = nil
    begin
      version = lookup[:version].to_i
    rescue
      version = 0
    end
    
    return version < 5 ? wrong_version_error : version
end
write_file(path, str) click to toggle source
# File lib/utils/strings.rb, line 47
def write_file path, str
    File.write(path, str)
end
wrong_version_error() click to toggle source
# File lib/utils/strings.rb, line 34
def wrong_version_error
    puts 'Must provide a version option'
    return false
end