Class: ZAWS::Helper::Option

Inherits:
Object
  • Object
show all
Defined in:
lib/zaws/helper/option.rb

Class Method Summary collapse

Class Method Details

.absent(optarr, opt_hash) ⇒ Object



9
10
11
# File 'lib/zaws/helper/option.rb', line 9

def self.absent(optarr, opt_hash)
  optarr.inject([]) { |missing, opt| opt_hash[opt] ? missing : missing << opt }
end

.exclusive?(optarr, opt_hash) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/zaws/helper/option.rb', line 13

def self.exclusive?(optarr, opt_hash)
  (optarr.inject(0) { |total, opt| opt_hash[opt] ? total + 1 : total }) <= 1
end

.exists?(optarr, opt_hash) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/zaws/helper/option.rb', line 5

def self.exists?(optarr, opt_hash)
  optarr.all? { |opt| opt_hash[opt] }
end

.minimum?(min, optarr, opt_hash) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/zaws/helper/option.rb', line 17

def self.minimum?(min, optarr, opt_hash)
  (optarr.inject(0) { |total, opt| opt_hash[opt] ? total + 1 : total }) >= min
end