Class: Embulk::Input::GoogleSpreadsheets::Typecast::LooseTypecast

Inherits:
StrictTypecast show all
Defined in:
lib/embulk/input/google_spreadsheets/typecast/loose_typecast.rb

Constant Summary

Constants inherited from StrictTypecast

StrictTypecast::BOOLEAN_FALSE_VALUES, StrictTypecast::BOOLEAN_TRUE_VALUES

Instance Attribute Summary

Attributes inherited from Base

#null_string

Instance Method Summary collapse

Methods inherited from Base

#initialize, #logger, #to_json

Constructor Details

This class inherits a constructor from Embulk::Input::GoogleSpreadsheets::Typecast::Base

Instance Method Details

#as_boolean(value) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/embulk/input/google_spreadsheets/typecast/loose_typecast.rb', line 44

def as_boolean(value)
  begin
    super
  rescue => e
    if e.is_a?(TypecastError)
      logger.trace{"`embulk-input-google_spreadsheets`: Fallback to nil, because of '#{e}'"}
      return nil
    end
    raise e
  end
end

#as_double(value) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/embulk/input/google_spreadsheets/typecast/loose_typecast.rb', line 32

def as_double(value)
  begin
    super
  rescue => e
    if e.is_a?(TypecastError)
      logger.trace{"`embulk-input-google_spreadsheets`: Fallback to nil, because of '#{e}'"}
      return nil
    end
    raise e
  end
end

#as_json(value) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
# File 'lib/embulk/input/google_spreadsheets/typecast/loose_typecast.rb', line 68

def as_json(value)
  begin
    super
  rescue => e
    if e.is_a?(TypecastError)
      logger.trace{"`embulk-input-google_spreadsheets`: Fallback to nil, because of '#{e}'"}
      return nil
    end
    raise e
  end
end

#as_long(value) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/embulk/input/google_spreadsheets/typecast/loose_typecast.rb', line 20

def as_long(value)
  begin
    super
  rescue => e
    if e.is_a?(TypecastError)
      logger.trace{"`embulk-input-google_spreadsheets`: Fallback to nil, because of '#{e}'"}
      return nil
    end
    raise e
  end
end

#as_string(value) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/embulk/input/google_spreadsheets/typecast/loose_typecast.rb', line 8

def as_string(value)
  begin
    super
  rescue => e
    if e.is_a?(TypecastError)
      logger.trace{"`embulk-input-google_spreadsheets`: Fallback to nil, because of '#{e}'"}
      return nil
    end
    raise e
  end
end

#as_timestamp(value, timestamp_format = nil, timezone = nil) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
# File 'lib/embulk/input/google_spreadsheets/typecast/loose_typecast.rb', line 56

def as_timestamp(value, timestamp_format = nil, timezone = nil)
  begin
    super
  rescue => e
    if e.is_a?(TypecastError)
      logger.trace{"`embulk-input-google_spreadsheets`: Fallback to nil, because of '#{e}'"}
      return nil
    end
    raise e
  end
end