Class: Quandl::Sandbox::Dataset

Inherits:
Object
  • Object
show all
Defined in:
lib/quandl/sandbox/dataset.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(output) ⇒ Dataset

Returns a new instance of Dataset.



11
12
13
14
15
16
17
18
# File 'lib/quandl/sandbox/dataset.rb', line 11

def initialize(output)
  rows = output.split("\n")
  self.full_code = rows.shift.strip
  self.name = rows.shift.strip
  self.description = rows.shift.strip
  self.column_names = rows.shift
  self.data = rows.join("\n").strip
end

Instance Attribute Details

#codeObject

Returns the value of attribute code.



3
4
5
# File 'lib/quandl/sandbox/dataset.rb', line 3

def code
  @code
end

#column_namesObject

Returns the value of attribute column_names.



3
4
5
# File 'lib/quandl/sandbox/dataset.rb', line 3

def column_names
  @column_names
end

#dataObject

Returns the value of attribute data.



3
4
5
# File 'lib/quandl/sandbox/dataset.rb', line 3

def data
  @data
end

#descriptionObject

Returns the value of attribute description.



3
4
5
# File 'lib/quandl/sandbox/dataset.rb', line 3

def description
  @description
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/quandl/sandbox/dataset.rb', line 3

def name
  @name
end

#source_codeObject

Returns the value of attribute source_code.



3
4
5
# File 'lib/quandl/sandbox/dataset.rb', line 3

def source_code
  @source_code
end

Class Method Details

.from_output(outputs) ⇒ Object



5
6
7
8
9
# File 'lib/quandl/sandbox/dataset.rb', line 5

def self.from_output(outputs)
  outputs.split("----\n").collect do |output|
    self.new(output)
  end
end

Instance Method Details

#full_codeObject



37
38
39
# File 'lib/quandl/sandbox/dataset.rb', line 37

def full_code
  [source_code, code].join('/')
end

#full_code=(value) ⇒ Object



31
32
33
34
35
# File 'lib/quandl/sandbox/dataset.rb', line 31

def full_code=(value)
  value = value.split('/')
  self.source_code = value[0]
  self.code = value[1]
end

#inspectObject



20
21
22
23
24
# File 'lib/quandl/sandbox/dataset.rb', line 20

def inspect
  "<##{self.class.name}" + 
  [:full_code, :name, :description, :column_names].inject({}){|m,k| m[k] = self.send(k); m }.to_s +
  " >"
end