Class: Thrift::Types::Known::Duration::Duration

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

Constant Summary collapse

NAME =
'Duration'.freeze
NAMESPACE =
'types.known.duration'.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_number(v) ⇒ Object



15
16
17
# File 'lib/thrift/types/known/duration/duration.rb', line 15

def from_number(v)
  Duration.new(seconds: v.to_i, nanos: ((v % 1) * 1e9).to_i)
end

Instance Method Details

#struct_fieldsObject



47
# File 'lib/thrift/types/known/duration/duration_types.rb', line 47

def struct_fields; FIELDS; end

#to_numberObject



20
21
22
# File 'lib/thrift/types/known/duration/duration.rb', line 20

def to_number
  seconds + nanos / 1e9
end

#validateObject



49
50
51
52
# File 'lib/thrift/types/known/duration/duration_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