module Quandl::Format::Dataset::Client

Public Instance Methods

client() click to toggle source
# File lib/quandl/format/dataset/client.rb, line 38
def client
  @client ||= find_or_build_client
end
client=(value) click to toggle source
# File lib/quandl/format/dataset/client.rb, line 41
def client=(value)
  raise ArgumentError, "Expected Quandl::Client::Dataset received #{value.class}" unless value.is_a?(Quandl::Client::Dataset)
  @client = value
end
full_url() click to toggle source
# File lib/quandl/format/dataset/client.rb, line 30
def full_url
  client.full_url
end
human_error(name, message) click to toggle source
# File lib/quandl/format/dataset/client.rb, line 25
def human_error(name, message)
  message = message.join(', ') if message.respond_to?(:join)
  "    #{name}: #{message}\n"
end
human_errors() click to toggle source
# File lib/quandl/format/dataset/client.rb, line 15
def human_errors
  m = "#{client.human_status} \t #{client.full_url}"
  return m if errors.blank?
  m += "\n  errors: \n"
  m += errors.collect do |error_type, messages|
    next human_error(error_type, messages)  unless messages.is_a?(Hash)
    messages.collect{|n,m| human_error(n, m) }
  end.flatten.compact.join
end
upload() click to toggle source
# File lib/quandl/format/dataset/client.rb, line 34
def upload
  client.save if valid?
end

Protected Instance Methods

client_should_be_valid!() click to toggle source
# File lib/quandl/format/dataset/client.rb, line 49
def client_should_be_valid!
  if !client.valid?
    client.errors.each{|err, value| self.errors.add( err, value ) }
    return false 
  end
  true
end
find_or_build_client() click to toggle source
# File lib/quandl/format/dataset/client.rb, line 57
def find_or_build_client
  @client ||= Quandl::Client::Dataset.find(full_code)
  @client = Quandl::Client::Dataset.new unless @client.try(:exists?)
  @client.assign_attributes(attributes)
  @client
end