quandl_operation 0.1.12 → 0.1.13
Sign up to get free protection for your applications and to get access to all the features.
data/UPGRADE.md
CHANGED
@@ -2,4 +2,10 @@ class Array
|
|
2
2
|
def self.forwardable_methods
|
3
3
|
[:reject, :keep_if, :permutation, :to_a, :cycle, :drop, :take_while, :map, :rotate, :each_slice, :pack, :select!, :combination, :repeated_combination, :shift, :select, :reverse!, :==, :clear, :rotate!, :inspect, :iter_for_each, :sort_by!, :compact!, :|, :copy_data_simple, :nitems, :zip, :take, :rassoc, :flatten!, :join, :compact, :[]=, :frozen?, :slice!, :drop_while, :reverse_each, :shuffle, :slice, :reverse, :insert, :uniq, :first, :count, :fetch, :hash, :to_ary, :find_index, :replace, :-, :product, :iter_for_reverse_each, :pop, :push, :sort, :fill, :uniq!, :length, :&, :flatten, :repeated_permutation, :[], :shuffle!, :sort!, :sample, :include?, :<<, :dimensions, :collect, :+, :rindex, :<=>, :eql?, :indices, :collect!, :iter_for_each_index, :iter_for_each_with_index, :index, :*, :indexes, :copy_data, :delete, :to_s, :assoc, :delete_at, :unshift, :delete_if, :empty?, :reject!, :last, :size, :concat, :map!, :at, :each_index, :transpose, :values_at, :each, :enum_cons, :group_by, :enum_with_index, :entries, :with_object, :chunk, :each_with_index, :min, :inject, :one?, :partition, :enum_slice, :none?, :max_by, :any?, :flat_map, :reduce, :each_entry, :find, :minmax_by, :collect_concat, :each_cons, :member?, :max, :sort_by, :detect, :all?, :minmax, :grep, :each_with_object, :find_all]
|
4
4
|
end
|
5
|
+
def average
|
6
|
+
self.sum / self.count
|
7
|
+
end
|
8
|
+
def extract_options
|
9
|
+
last.is_a?(::Hash) ? last : {}
|
10
|
+
end
|
5
11
|
end
|
@@ -26,4 +26,30 @@ class Date
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
+
def ranging_until( date )
|
30
|
+
self..date
|
31
|
+
end
|
32
|
+
|
33
|
+
def occurrences_of_frequency_ahead( occurrences, freq )
|
34
|
+
occurrences_of_frequency_ago( occurrences.to_i * -1, freq )
|
35
|
+
end
|
36
|
+
|
37
|
+
def occurrences_of_frequency_ago( occurrences, freq )
|
38
|
+
occurrences_of_frequency( occurrences, freq )
|
39
|
+
end
|
40
|
+
|
41
|
+
def occurrences_of_frequency( occurrences, freq )
|
42
|
+
# ensure occurrences is an integer
|
43
|
+
occurrences = occurrences.to_i
|
44
|
+
case freq.try(:to_sym)
|
45
|
+
when :weekly then self - occurrences.weeks
|
46
|
+
when :monthly then self - occurrences.months
|
47
|
+
when :quarterly then self - ( occurrences * 3 ).months
|
48
|
+
when :annual then self - occurrences.years
|
49
|
+
when :annually then self - occurrences.years
|
50
|
+
else
|
51
|
+
self - occurrences
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
29
55
|
end
|
@@ -17,10 +17,39 @@ class Time
|
|
17
17
|
|
18
18
|
end
|
19
19
|
|
20
|
+
def week_from_beginning_to_end
|
21
|
+
(self.beginning_of_week .. self.end_of_week)
|
22
|
+
end
|
23
|
+
def this_week?
|
24
|
+
self.week_from_beginning_to_end.cover?(Time.now)
|
25
|
+
end
|
26
|
+
|
27
|
+
def month_from_beginning_to_end
|
28
|
+
(self.beginning_of_month .. self.end_of_month)
|
29
|
+
end
|
30
|
+
def this_month?
|
31
|
+
self.month_from_beginning_to_end.cover?(Time.now)
|
32
|
+
end
|
33
|
+
|
34
|
+
def round(seconds = 60)
|
35
|
+
Time.at((self.to_f / seconds).round * seconds)
|
36
|
+
end
|
37
|
+
|
38
|
+
def floor(seconds = 60)
|
39
|
+
Time.at((self.to_f / seconds).floor * seconds)
|
40
|
+
end
|
41
|
+
|
20
42
|
def microseconds
|
21
43
|
(self.to_f * 1000.0).to_i
|
22
44
|
end
|
23
45
|
|
46
|
+
def self.elapsed(message=nil, &block)
|
47
|
+
timer = Time.now
|
48
|
+
result = block.call
|
49
|
+
puts "#{message} (#{timer.elapsed.microseconds}ms)"
|
50
|
+
result
|
51
|
+
end
|
52
|
+
|
24
53
|
def elapsed
|
25
54
|
elapsed_since(Time.now)
|
26
55
|
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.1.
|
4
|
+
version: 0.1.13
|
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-10-
|
12
|
+
date: 2013-10-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -146,6 +146,7 @@ files:
|
|
146
146
|
- lib/quandl/operation/core_ext/array.rb
|
147
147
|
- lib/quandl/operation/core_ext/date.rb
|
148
148
|
- lib/quandl/operation/core_ext/float.rb
|
149
|
+
- lib/quandl/operation/core_ext/string.rb
|
149
150
|
- lib/quandl/operation/core_ext/time.rb
|
150
151
|
- lib/quandl/operation/parse.rb
|
151
152
|
- lib/quandl/operation/transform.rb
|