Class: ZAWS::Helper::Option
- Inherits:
-
Object
- Object
- ZAWS::Helper::Option
- Defined in:
- lib/zaws/helper/option.rb
Class Method Summary collapse
- .absent(optarr, opt_hash) ⇒ Object
- .exclusive?(optarr, opt_hash) ⇒ Boolean
- .exists?(optarr, opt_hash) ⇒ Boolean
- .minimum?(min, optarr, opt_hash) ⇒ Boolean
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
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
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
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 |