Class: Puppet::Pops::Types::PBooleanType
- Inherits:
-
PScalarDataType
- Object
- TypedModelObject
- PAnyType
- PScalarType
- PScalarDataType
- Puppet::Pops::Types::PBooleanType
- Defined in:
- lib/puppet/pops/types/types.rb
Constant Summary collapse
- DEFAULT =
PBooleanType.new
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from PScalarType
Methods inherited from PAnyType
#==, #accept, #assignable?, #callable?, #callable_args?, #callable_with?, #check_self_recursion, #create, create, #eql?, #generalize, #hash, #iterable?, #iterable_type, #kind_of_callable?, #name, #new_function, #normalize, #really_instance?, #resolve, #roundtrip_with_string?, simple_name, #simple_name, #to_alias_expanded_s, #to_s
Methods inherited from TypedModelObject
_pcore_type, create_ptype, register_ptypes
Methods included from Visitable
Methods included from PuppetObject
#_pcore_all_contents, #_pcore_contents, #_pcore_init_hash, #_pcore_type
Class Method Details
.new_function(_, loader) ⇒ Object
1694 1695 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 |
# File 'lib/puppet/pops/types/types.rb', line 1694 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
1686 1687 1688 |
# File 'lib/puppet/pops/types/types.rb', line 1686 def self.register_ptype(loader, ir) create_ptype(loader, ir, 'ScalarDataType') end |
Instance Method Details
#instance?(o, guard = nil) ⇒ Boolean
1690 1691 1692 |
# File 'lib/puppet/pops/types/types.rb', line 1690 def instance?(o, guard = nil) o == true || o == false end |