Class: Embulk::Guess::TimeFormatGuess::GuessMatch
- Inherits:
-
Object
- Object
- Embulk::Guess::TimeFormatGuess::GuessMatch
- Defined in:
- lib/embulk/guess/time_format_guess.rb
Instance Attribute Summary collapse
-
#part_options ⇒ Object
readonly
Returns the value of attribute part_options.
Instance Method Summary collapse
- #format ⇒ Object
-
#initialize(delimiters, parts, part_options) ⇒ GuessMatch
constructor
A new instance of GuessMatch.
- #merge!(another_in_group) ⇒ Object
- #mergeable_group ⇒ Object
Constructor Details
#initialize(delimiters, parts, part_options) ⇒ GuessMatch
Returns a new instance of GuessMatch.
22 23 24 25 26 |
# File 'lib/embulk/guess/time_format_guess.rb', line 22 def initialize(delimiters, parts, ) @delimiters = delimiters @parts = parts @part_options = end |
Instance Attribute Details
#part_options ⇒ Object (readonly)
Returns the value of attribute part_options.
125 126 127 |
# File 'lib/embulk/guess/time_format_guess.rb', line 125 def @part_options end |
Instance Method Details
#format ⇒ Object
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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/embulk/guess/time_format_guess.rb', line 28 def format format = '' @parts.size.times do |i| format << @delimiters[i-1] if i != 0 option = @part_options[i] case @parts[i] when :year format << '%Y' when :month case option when :zero format << '%m' when :blank #format << '%_m' # not supported format << '%m' when :none #format << '%-m' # not supported format << '%m' else format << '%m' end when :day case option when :zero format << '%d' when :blank format << '%e' when :none format << '%d' # not supported else format << '%d' end when :hour case option when :zero format << '%H' when :blank format << '%k' when :none format << '%k' # not supported else format << '%H' end when :minute # heading options are not supported format << '%M' when :second # heading options are not supported format << '%S' when :frac if option <= 3 format << '%L' #elsif option <= 6 # format << '%6N' #elsif option <= 6 # format << '%6N' #elsif option <= 9 # format << '%9N' #elsif option <= 12 # format << '%12N' #elsif option <= 15 # format << '%15N' #elsif option <= 18 # format << '%18N' #elsif option <= 21 # format << '%21N' #elsif option <= 24 # format << '%24N' else format << '%N' end when :zone_off format << '%z' when :zone_abb format << '%Z' else raise "Unknown part: #{@parts[i]}" end end return format end |
#merge!(another_in_group) ⇒ Object
127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/embulk/guess/time_format_guess.rb', line 127 def merge!(another_in_group) = another_in_group. @part_options.size.times do |i| @part_options[i] ||= [i] if @part_options[i] == nil [i] elsif [i] == nil @part_options[i] else [@part_options[i], [i]].sort.last end end end |
#mergeable_group ⇒ Object
121 122 123 |
# File 'lib/embulk/guess/time_format_guess.rb', line 121 def mergeable_group [@delimiters, @parts] end |