Sha256: d4a6e14499c47f703079a62052a34619a6c609b2be3707f389d6e09487f2bd30
Contents?: true
Size: 1.44 KB
Versions: 3
Compression:
Stored size: 1.44 KB
Contents
# frozen_string_literal: true require 'time' module OGR module InternalHelpers def self.included(base) base.extend(ClassMethods) end # @private module ClassMethods # Makes the interface consistent with the access flags for GDAL. # # @param flag [String] 'w' for writing, 'r' for reading. def _boolean_access_flag(flag) case flag when 'w' then true when 'r' then false else raise "Invalid access_flag '#{flag}'. Use 'r' or 'w'." end end # OGR's time zone rules: # * 0 = unknown # * 1 = local time # * 100 = GMT # # This converts the OGR integer into something usable by Ruby's DateTime. # # @param time_zone [Integer] def _format_time_zone_for_ruby(time_zone) case time_zone when 0 then nil when 1 then (Time.now.getlocal.utc_offset / 3600).to_s when 100 then '+0' else raise "Unable to process time zone: #{time_zone}" end end # OGR's time zone rules: # * 0 = unknown # * 1 = local time # * 100 = GMT # # This converts Ruby's DateTime time zone info into OGR's integer. # # @param time_zone [String] def _format_time_zone_for_ogr(time_zone) if /(00:00|GMT)\z/.match?(time_zone) 100 elsif time_zone 1 else 0 end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ffi-gdal-1.0.2 | lib/ogr/internal_helpers.rb |
ffi-gdal-1.0.1 | lib/ogr/internal_helpers.rb |
ffi-gdal-1.0.0 | lib/ogr/internal_helpers.rb |