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, #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
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
|
# File 'lib/puppet/pops/types/types.rb', line 1607
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
1599
1600
1601
|
# File 'lib/puppet/pops/types/types.rb', line 1599
def self.register_ptype(loader, ir)
create_ptype(loader, ir, 'ScalarType')
end
|
Instance Method Details
#instance?(o, guard = nil) ⇒ Boolean
1603
1604
1605
|
# File 'lib/puppet/pops/types/types.rb', line 1603
def instance?(o, guard = nil)
o == true || o == false
end
|