]> git.proxmox.com Git - ceph.git/blob - ceph/src/arrow/ruby/red-arrow/lib/arrow/time32-data-type.rb
import quincy 17.2.0
[ceph.git] / ceph / src / arrow / ruby / red-arrow / lib / arrow / time32-data-type.rb
1 # Licensed to the Apache Software Foundation (ASF) under one
2 # or more contributor license agreements. See the NOTICE file
3 # distributed with this work for additional information
4 # regarding copyright ownership. The ASF licenses this file
5 # to you under the Apache License, Version 2.0 (the
6 # "License"); you may not use this file except in compliance
7 # with the License. You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing,
12 # software distributed under the License is distributed on an
13 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 # KIND, either express or implied. See the License for the
15 # specific language governing permissions and limitations
16 # under the License.
17
18 module Arrow
19 class Time32DataType
20 alias_method :initialize_raw, :initialize
21 private :initialize_raw
22
23 # Creates a new {Arrow::Time32DataType}.
24 #
25 # @overload initialize(unit)
26 #
27 # @param unit [Arrow::TimeUnit, Symbol] The unit of the
28 # time32 data type.
29 #
30 # The unit must be second or millisecond.
31 #
32 # @example Create a time32 data type with Arrow::TimeUnit
33 # Arrow::Time32DataType.new(Arrow::TimeUnit::MILLI)
34 #
35 # @example Create a time32 data type with Symbol
36 # Arrow::Time32DataType.new(:milli)
37 #
38 # @overload initialize(description)
39 #
40 # @param description [Hash] The description of the time32 data
41 # type. It must have `:unit` value.
42 #
43 # @option description [Arrow::TimeUnit, Symbol] :unit The unit of
44 # the time32 data type.
45 #
46 # The unit must be second or millisecond.
47 #
48 # @example Create a time32 data type with Arrow::TimeUnit
49 # Arrow::Time32DataType.new(unit: Arrow::TimeUnit::MILLI)
50 #
51 # @example Create a time32 data type with Symbol
52 # Arrow::Time32DataType.new(unit: :milli)
53 def initialize(unit)
54 if unit.is_a?(Hash)
55 description = unit
56 unit = description[:unit]
57 end
58 initialize_raw(unit)
59 end
60 end
61 end