Class: Puppet::Pops::Types::PBooleanType
Constant Summary
collapse
- DEFAULT =
PBooleanType.new
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from PAnyType
#==, #accept, #assignable?, #callable?, #callable_args?, #callable_with?, #check_self_recursion, #create, #eql?, #generalize, #hash, #iterable?, #iterable_type, #kind_of_callable?, #name, #new_function, #normalize, #really_instance?, #resolve, #simple_name, simple_name, #to_alias_expanded_s, #to_s
_ptype, create_ptype, register_ptypes
Methods included from Visitable
#accept
#_ptype
Class Method Details
.new_function(_, loader) ⇒ Object
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
|
# File 'lib/puppet/pops/types/types.rb', line 1696
def self.new_function(_, loader)
@new_function ||= Puppet::Functions.create_loaded_function(:new_boolean, loader) do
dispatch :from_args do
param 'Variant[Undef, Integer, Float, Boolean, String]', :from
end
def from_args(from)
from = from.downcase if from.is_a?(String)
case from
when NilClass
throw :undefined_value
when Float
from != 0.0
when Integer
from != 0
when true, false
from
when 'false', 'no', 'n'
false
when 'true', 'yes', 'y'
true
else
raise TypeConversionError.new("Value '#{from}' of type '#{from.class}' cannot be converted to Boolean")
end
end
end
end
|
.register_ptype(loader, ir) ⇒ Object
1688
1689
1690
|
# File 'lib/puppet/pops/types/types.rb', line 1688
def self.register_ptype(loader, ir)
create_ptype(loader, ir, 'ScalarType')
end
|
Instance Method Details
#instance?(o, guard = nil) ⇒ Boolean
1692
1693
1694
|
# File 'lib/puppet/pops/types/types.rb', line 1692
def instance?(o, guard = nil)
o == true || o == false
end
|