module Embulk::Input::GoogleSpreadsheets::TypecastFactory
Public Class Methods
create(type, task)
click to toggle source
# File lib/embulk/input/google_spreadsheets/typecast_factory.rb, line 7 def self.create(type, task) raise GoogleSpreadsheets::ConfigError.new("`embulk-input-google_spreadsheets`: unknown typecast '#{type}'") if type.nil? or !type.is_a?(String) type = type.downcase path = build_typecast_class_path(type) raise GoogleSpreadsheets::ConfigError.new("`embulk-input-google_spreadsheets`: Typecast class path does not exist '#{path}'") unless File.exist?(path) require path typecast_class(type).new(task) end
Private Class Methods
build_typecast_class_path(type)
click to toggle source
# File lib/embulk/input/google_spreadsheets/typecast_factory.rb, line 24 def self.build_typecast_class_path(type) File.expand_path("typecast/#{type}_typecast.rb", __dir__) end
camelize(snake)
click to toggle source
# File lib/embulk/input/google_spreadsheets/typecast_factory.rb, line 28 def self.camelize(snake) snake.split('_').map{|w| w[0] = w[0].upcase; w}.join end
typecast_class(type)
click to toggle source
# File lib/embulk/input/google_spreadsheets/typecast_factory.rb, line 20 def self.typecast_class(type) Object.const_get("Embulk::Input::GoogleSpreadsheets::Typecast::#{camelize(type)}Typecast") end