Sha256: d146af9846bf8d1a6da7d3927f8ccb18a3f25ebe8decdaee330f9778993f0bfd

Contents?: true

Size: 657 Bytes

Versions: 1

Compression:

Stored size: 657 Bytes

Contents

require 'my_chart/x'

module MyChart
  module Dsl
    module Material

      def material dat=nil, name: ALL_DATA, &blk
        data = (dat ? dat : blk.call)
        raw_data[name] = MyChart::X.new data
      end

      def select name, opt={}, &blk
        from = opt[:from] || ALL_DATA
        x = raw_data[from]
        raise Exception, '#{from} is not defined' unless x
        result = x.select &blk
        name = opt[:from] ? "#{name}__from__#{opt[:from]}".to_sym : name
        raw_data[name] = result
      end

      def raw_data
        @raw_data ||= {}
      end

      def get_x id
        raw_data[id || ALL_DATA]
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
my_chart-0.1.3 lib/my_chart/dsl/material.rb