Add Utils module
This commit is contained in:
@@ -6,6 +6,7 @@ require 'calligraphy/xml/namespace'
|
||||
require 'calligraphy/xml/node'
|
||||
require 'calligraphy/xml/utils'
|
||||
|
||||
require 'calligraphy/utils'
|
||||
require 'calligraphy/resource'
|
||||
|
||||
require 'calligraphy/web_dav_request'
|
||||
|
||||
22
lib/calligraphy/utils.rb
Normal file
22
lib/calligraphy/utils.rb
Normal file
@@ -0,0 +1,22 @@
|
||||
module Calligraphy
|
||||
module Utils
|
||||
TRUE_VALUES = [true, 1, '1', 't', 'T', 'true', 'TRUE']
|
||||
FALSE_VALUES = [false, 0, '0', 'f', 'F', 'false', 'FALSE']
|
||||
|
||||
def is_true?(val)
|
||||
TRUE_VALUES.include? val
|
||||
end
|
||||
|
||||
def is_false?(val)
|
||||
FALSE_VALUES.include? val
|
||||
end
|
||||
|
||||
def join_paths(*paths)
|
||||
paths.join '/'
|
||||
end
|
||||
|
||||
def split_and_pop(path:, separator: '/')
|
||||
path.split(separator)[0..-2]
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user