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?, #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
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
|
# File 'lib/puppet/pops/types/types.rb', line 1648
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
1640
1641
1642
|
# File 'lib/puppet/pops/types/types.rb', line 1640
def self.register_ptype(loader, ir)
create_ptype(loader, ir, 'ScalarType')
end
|
Instance Method Details
#instance?(o, guard = nil) ⇒ Boolean
1644
1645
1646
|
# File 'lib/puppet/pops/types/types.rb', line 1644
def instance?(o, guard = nil)
o == true || o == false
end
|