Sha256: 6e5e56333ab58dd6271d2fe4527928e4d44fd8ef1b22f0a10c6627a25b202733

Contents?: true

Size: 849 Bytes

Versions: 4

Compression:

Stored size: 849 Bytes

Contents

module Quandl
  class Data < ModelBase
    include Quandl::Operations::List

    def self.create_list_from_response(_response, data)
      values = data['dataset_data'].delete('data')
      metadata = data['dataset_data']
      Quandl::List.new(self, values, metadata)
    end

    def self.list_path
      'datasets/:database_code/:dataset_code/data'
    end

    def initialize(data, options = {})
      converted_column_names = options[:meta]['column_names'].map { |cn| Quandl::Util.methodize(cn) }
      @raw_data = Quandl::Util.convert_to_dates(Hash[converted_column_names.zip(data)])
      @meta = options[:meta]
    end

    def column_names
      @meta['column_names']
    end

    private

    def method_missing(method_name, *args, &block)
      return @meta[method_name.to_s] if @meta.key?(method_name.to_s)
      super
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
quandl-1.0.1 lib/quandl/model/data.rb
quandl-1.0.0 lib/quandl/model/data.rb
quandl-1.0.0.rc2 lib/quandl/model/data.rb
quandl-1.0.0.rc1 lib/quandl/model/data.rb