Sha256: 38cb95be81025e30eb03dbf5b7f9bbba5cebb26749626668f6fc8f6f4d179699

Contents?: true

Size: 544 Bytes

Versions: 2

Compression:

Stored size: 544 Bytes

Contents

require 'json'

module GDAL
  module ColorEntryExtensions

    # @param include_fourth [Boolean] Turn off in case you don't want the fourth
    #   color in the array.
    # @return [Array]
    def to_a(include_fourth=true)
      if include_fourth
        [color1, color2, color3, color4]
      else
        [color1, color2, color3]
      end
    end

    def as_json
      {
        color1: color1,
        color2: color2,
        color3: color3,
        color4: color4
      }
    end

    def to_json
      as_json.to_json
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ffi-gdal-1.0.0.beta3 lib/gdal/color_entry_extensions.rb
ffi-gdal-1.0.0.beta1 lib/gdal/color_entry_extensions.rb