quandl_operation 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -49,7 +49,7 @@ class Parse
49
49
  end
50
50
 
51
51
  def unknown_date_format_to_julian(data)
52
- return data unless data.present? && data[0] && data[0][0]
52
+ return data if data_missing_rows?(data)
53
53
  date = data[0][0]
54
54
  # formatted like: "2013-06-18"
55
55
  return date_to_julian(data) if date.is_a?(String) && date =~ /[0-9]{4}-[0-9]{2}-[0-9]{2}/
@@ -58,7 +58,7 @@ class Parse
58
58
  end
59
59
 
60
60
  def date_to_julian(data)
61
- return data if data[0][0].is_a?(Integer)
61
+ return data if data_missing_rows?(data) || data[0][0].is_a?(Integer)
62
62
  # dont alter by reference
63
63
  result = []
64
64
  # for each row
@@ -78,7 +78,7 @@ class Parse
78
78
  end
79
79
 
80
80
  def julian_to_date(data)
81
- return data if data[0][0].is_a?(Date)
81
+ return data if data_missing_rows?(data) || data[0][0].is_a?(Date)
82
82
  # dont alter by reference
83
83
  result = []
84
84
  # for each row
@@ -96,14 +96,14 @@ class Parse
96
96
 
97
97
  def julian_string_to_integer(data)
98
98
  # skip when already formatted correctly
99
- return data if data[0][0].is_a?(Integer) || data[0][0].is_a?(Date)
99
+ return data if data_missing_rows?(data) || data[0][0].is_a?(Integer) || data[0][0].is_a?(Date)
100
100
  # otherwise cast string jds to int
101
101
  data.collect{|r| r[0] = r[0].to_i; r }
102
102
  end
103
103
 
104
104
  def values_to_float(data)
105
105
  # skip unless value is a string
106
- return data unless data[0][1].is_a?(String)
106
+ return data if data_missing_rows?(data) || !data[0][1].is_a?(String)
107
107
  # cast values to float
108
108
  data.collect do |row|
109
109
  new_row = [row[0]]
@@ -115,6 +115,14 @@ class Parse
115
115
  end
116
116
  end
117
117
 
118
+ def data_missing_rows?(data)
119
+ !data_has_rows?(data)
120
+ end
121
+
122
+ def data_has_rows?(data)
123
+ data.is_a?(Array) && data[0].is_a?(Array) && data[0][0].present?
124
+ end
125
+
118
126
  end
119
127
 
120
128
  end
@@ -1,5 +1,5 @@
1
1
  module Quandl
2
2
  module Operation
3
- VERSION = "0.0.7"
3
+ VERSION = "0.0.8"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quandl_operation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-19 00:00:00.000000000 Z
12
+ date: 2013-06-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake