Class: Thrift::Types::Known::Timestamp::Timestamp

Inherits:
Object
  • Object
show all
Includes:
Struct, Struct_Union
Defined in:
lib/thrift/types/known/timestamp/timestamp.rb,
lib/thrift/types/known/timestamp/timestamp_types.rb,
lib/thrift/types/known/timestamp/timestamp_types.rb

Constant Summary collapse

NAME =
'Timestamp'.freeze
NAMESPACE =
'types.known.timestamp'.freeze
LEGACY_ANNOTATIONS =
{
}.freeze
STRUCTURED_ANNOTATIONS =
[
].freeze
THRIFT_FIELD_INDEX_SECONDS =
1
THRIFT_FIELD_INDEX_NANOS =
2
THRIFT_FIELD_SECONDS_LEGACY_ANNOTATIONS =
{
}.freeze
THRIFT_FIELD_SECONDS_STRUCTURED_ANNOTATIONS =
[
].freeze
THRIFT_FIELD_NANOS_LEGACY_ANNOTATIONS =
{
}.freeze
THRIFT_FIELD_NANOS_STRUCTURED_ANNOTATIONS =
[
].freeze
FIELDS =
{
  THRIFT_FIELD_INDEX_SECONDS => {type: ::Thrift::Types::I64, name: 'seconds', legacy_annotations: THRIFT_FIELD_SECONDS_LEGACY_ANNOTATIONS, structured_annotations: THRIFT_FIELD_SECONDS_STRUCTURED_ANNOTATIONS},
  THRIFT_FIELD_INDEX_NANOS => {type: ::Thrift::Types::I32, name: 'nanos', legacy_annotations: THRIFT_FIELD_NANOS_LEGACY_ANNOTATIONS, structured_annotations: THRIFT_FIELD_NANOS_STRUCTURED_ANNOTATIONS}
}.freeze

Constants included from Struct_Union

Struct_Union::CONTAINER_TYPES

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Struct

#<=>, #==, append_features, #differences, #eql?, field_accessor, #fields_with_default_values, generate_accessors, #hash, #initialize, #inspect, qmark_isset_method, #read, #write

Methods included from Struct_Union

#each_field, #field_info, #inspect_collection, #inspect_field, #is_container?, #name_to_id, #read_field, #sorted_field_ids, #write_container, #write_data

Class Method Details

.from_time(v) ⇒ Object



19
20
21
# File 'lib/thrift/types/known/timestamp/timestamp.rb', line 19

def from_time(v)
  Timestamp.new(seconds: v.to_i, nanos: v.nsec)
end

Instance Method Details

#struct_fieldsObject



47
# File 'lib/thrift/types/known/timestamp/timestamp_types.rb', line 47

def struct_fields; FIELDS; end

#to_timeObject



24
25
26
# File 'lib/thrift/types/known/timestamp/timestamp.rb', line 24

def to_time
  Time.at(seconds, nanos, :nsec)
end

#validateObject



49
50
51
52
# File 'lib/thrift/types/known/timestamp/timestamp_types.rb', line 49

def validate
  raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field seconds is unset!') unless @seconds
  raise ::Thrift::ProtocolException.new(::Thrift::ProtocolException::UNKNOWN, 'Required field nanos is unset!') unless @nanos
end