Class: Puppet::Pops::Types::PTimestampType
- Inherits:
-
PAbstractTimeDataType
- Object
- TypedModelObject
- PAnyType
- PScalarType
- PAbstractTimeDataType
- Puppet::Pops::Types::PTimestampType
- Defined in:
- lib/puppet/pops/types/p_timestamp_type.rb
Constant Summary collapse
- DEFAULT =
PTimestampType.new(nil, nil)
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from PAbstractTimeDataType
#_assignable?, #convert_arg, #eql?, #from, #hash, #initialize, #intersect?, #merge, #numeric_from, #numeric_to, #to, #unbounded?
Methods inherited from PScalarType
Methods inherited from PAnyType
#==, #accept, #assignable?, #callable?, #callable_args?, #callable_with?, #check_self_recursion, create, #create, #eql?, #hash, #iterable?, #iterable_type, #kind_of_callable?, #loader, #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, #to_s
Constructor Details
This class inherits a constructor from Puppet::Pops::Types::PAbstractTimeDataType
Class Method Details
.new_function(type) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/puppet/pops/types/p_timestamp_type.rb', line 11 def self.new_function(type) @new_function ||= Puppet::Functions.create_loaded_function(:new_timestamp, type.loader) do local_types do type 'Formats = Variant[String[2],Array[String[2], 1]]' end dispatch :now do end dispatch :from_seconds do param 'Variant[Integer,Float]', :seconds end dispatch :from_string do param 'String[1]', :string optional_param 'Formats', :format optional_param 'String[1]', :timezone end dispatch :from_string_hash do param " Struct[{\n string => String[1],\n Optional[format] => Formats,\n Optional[timezone] => String[1]\n }]\n TYPE\n end\n\n def now\n Time::Timestamp.now\n end\n\n def from_string(string, format = :default, timezone = nil)\n Time::Timestamp.parse(string, format, timezone)\n end\n\n def from_string_hash(args_hash)\n Time::Timestamp.from_hash(args_hash)\n end\n\n def from_seconds(seconds)\n Time::Timestamp.new((seconds * Time::NSECS_PER_SEC).to_i)\n end\n end\nend\n", :hash_arg |
.register_ptype(loader, ir) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/puppet/pops/types/p_timestamp_type.rb', line 4 def self.register_ptype(loader, ir) create_ptype(loader, ir, 'ScalarType', 'from' => { KEY_TYPE => POptionalType.new(PTimestampType::DEFAULT), KEY_VALUE => nil }, 'to' => { KEY_TYPE => POptionalType.new(PTimestampType::DEFAULT), KEY_VALUE => nil } ) end |
Instance Method Details
#generalize ⇒ Object
58 59 60 |
# File 'lib/puppet/pops/types/p_timestamp_type.rb', line 58 def generalize DEFAULT end |
#impl_class ⇒ Object
62 63 64 |
# File 'lib/puppet/pops/types/p_timestamp_type.rb', line 62 def impl_class Time::Timestamp end |
#instance?(o, guard = nil) ⇒ Boolean
66 67 68 |
# File 'lib/puppet/pops/types/p_timestamp_type.rb', line 66 def instance?(o, guard = nil) o.is_a?(Time::Timestamp) && o >= @from && o <= @to end |