Module: OGR::InternalHelpers::ClassMethods
- Defined in:
- lib/ogr/internal_helpers.rb
Instance Method Summary collapse
-
#_boolean_access_flag(flag) ⇒ Object
Makes the interface consistent with the access flags for GDAL.
-
#_format_time_zone_for_ogr(time_zone) ⇒ Object
OGR’s time zone rules: * 0 = unknown * 1 = local time * 100 = GMT.
-
#_format_time_zone_for_ruby(time_zone) ⇒ Object
OGR’s time zone rules: * 0 = unknown * 1 = local time * 100 = GMT.
Instance Method Details
#_boolean_access_flag(flag) ⇒ Object
Makes the interface consistent with the access flags for GDAL.
16 17 18 19 20 21 22 |
# File 'lib/ogr/internal_helpers.rb', line 16 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 |
#_format_time_zone_for_ogr(time_zone) ⇒ Object
OGR’s time zone rules:
* 0 = unknown
* 1 = local time
* 100 = GMT
This converts Ruby’s DateTime time zone info into OGR’s integer.
49 50 51 52 53 54 55 56 57 |
# File 'lib/ogr/internal_helpers.rb', line 49 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 |
#_format_time_zone_for_ruby(time_zone) ⇒ Object
OGR’s time zone rules:
* 0 = unknown
* 1 = local time
* 100 = GMT
This converts the OGR integer into something usable by Ruby’s DateTime.
32 33 34 35 36 37 38 39 |
# File 'lib/ogr/internal_helpers.rb', line 32 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 |