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



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

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

.exclusive?(optarr, opt_hash) ⇒ Boolean

Returns:

  • (Boolean)


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

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)


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

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

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

Returns:

  • (Boolean)


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

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