Module: PuppetX::IntechWIFI::Logical
- Defined in:
- lib/puppet_x/intechwifi/logical.rb
Class Method Summary collapse
- .array_of_hashes_equal?(a, b) ⇒ Boolean
- .logical(value) ⇒ Object
- .logical_false(value) ⇒ Object
- .logical_true(value) ⇒ Object
- .string_true_or_false(value) ⇒ Object
Class Method Details
.array_of_hashes_equal?(a, b) ⇒ Boolean
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/puppet_x/intechwifi/logical.rb', line 48 def Logical.array_of_hashes_equal?(a, b) # Some quick answers.... return true if a.nil? and b.nil? return false if !a.kind_of?(Array) or !b.kind_of?(Array) return false if a.length != b.length a.all? {|val| b.include? val} b.all? {|val| a.include? val} end |
.logical(value) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/puppet_x/intechwifi/logical.rb', line 30 def Logical.logical(value) result = nil if logical_true(value) then result = 'enabled' end if logical_false(value) then result = 'disabled' end if result == nil then fail("Value '#{value}' could not be converted into a true/false value") end return result end |
.logical_false(value) ⇒ Object
25 26 27 28 |
# File 'lib/puppet_x/intechwifi/logical.rb', line 25 def Logical.logical_false(value) result = (value == false or value == :false or value == 'false' or value == :disabled or value == 'disabled' or value == :no or value == 'no') result end |
.logical_true(value) ⇒ Object
20 21 22 23 |
# File 'lib/puppet_x/intechwifi/logical.rb', line 20 def Logical.logical_true(value) result = (value == true or value == :true or value == 'true' or value == :enabled or value == 'enabled' or value == :yes or value == 'yes') result end |
.string_true_or_false(value) ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/puppet_x/intechwifi/logical.rb', line 38 def Logical.string_true_or_false(value) if logical_true(value) return 'true' end if logical_false(value) return 'false' end end |