Module: Quandl::Format::Dataset::Client

Extended by:
ActiveSupport::Concern
Included in:
Quandl::Format::Dataset
Defined in:
lib/quandl/format/dataset/client.rb

Instance Method Summary collapse

Instance Method Details

#clientObject



38
39
40
# File 'lib/quandl/format/dataset/client.rb', line 38

def client
  @client ||= find_or_build_client
end

#client=(value) ⇒ Object

Raises:

  • (ArgumentError)


41
42
43
44
# 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_urlObject



30
31
32
# File 'lib/quandl/format/dataset/client.rb', line 30

def full_url
  client.full_url
end

#human_error(name, message) ⇒ Object



25
26
27
28
# 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_errorsObject



15
16
17
18
19
20
21
22
23
# 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

#uploadObject



34
35
36
# File 'lib/quandl/format/dataset/client.rb', line 34

def upload
  client.save if valid?
end