Sha256: 9b4ff3a4ec5e7253b743f6b99d4d8f17f7632be7adbdd43cf82bc3c11bb7e60d

Contents?: true

Size: 678 Bytes

Versions: 3

Compression:

Stored size: 678 Bytes

Contents

require 'json'

module GDAL
  module ColorEntryMixins
    module Extensions
      # @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(_options = nil)
        {
          color1: color1,
          color2: color2,
          color3: color3,
          color4: color4
        }
      end

      # @return [String]
      def to_json(options = nil)
        as_json(options).to_json
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ffi-gdal-1.0.0.beta6 lib/gdal/color_entry_mixins/extensions.rb
ffi-gdal-1.0.0.beta5 lib/gdal/color_entry_mixins/extensions.rb
ffi-gdal-1.0.0.beta4 lib/gdal/color_entry_mixins/extensions.rb