Add Utils module

This commit is contained in:
Brandon Robins
2017-10-25 23:53:05 -05:00
parent 0efbdb57ec
commit ee3008fa90
2 changed files with 23 additions and 0 deletions

View File

@@ -6,6 +6,7 @@ require 'calligraphy/xml/namespace'
require 'calligraphy/xml/node' require 'calligraphy/xml/node'
require 'calligraphy/xml/utils' require 'calligraphy/xml/utils'
require 'calligraphy/utils'
require 'calligraphy/resource' require 'calligraphy/resource'
require 'calligraphy/web_dav_request' require 'calligraphy/web_dav_request'

22
lib/calligraphy/utils.rb Normal file
View 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