Sha256: 00e3ecf7daecefe33c2abd6bb21f9147240cdcf1e6c049b5af91d544cc4f05dd

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

Contents

require 'amcharts/uses_settings'

module AmCharts
  class ExportSettings
    class Menu
      include UsesSettings

      def initialize(*)
        super

        if defined? Rails
          @settings.icon ||= ActionController::Base.helpers.asset_path('amcharts/export.png')
        end
      end

      def formats
        formats = []
        formats << @settings[:format].to_s.downcase.to_sym if @settings[:format]

        if @settings[:items]
          @settings[:items].each do |i|
            formats << i[:format].to_s.downcase.to_sym if i[:format]
          end
        end

        formats
      end
    end

    attr_reader :settings, :menus

    def initialize(&block)
      @settings = Settings.new
      @menus = Collection[Menu]
      instance_exec(self, &block) if block_given?
    end

    def pdf?
      return false if menus.empty?
      menus.flat_map(&:formats).any?{ |f| f == :pdf }
    end
  private

    def method_missing(name, *args, &block)
      @settings.send(name, *args, &block)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
amcharts.rb-3.4.7.3 lib/amcharts/export_settings.rb