cepc_coinbase 0.9.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/cepc_coinbase.rb +229 -0
  3. metadata +60 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ca5dcfabe58e7c74c9cc43c5c7e3782831625a052235633f003c958ebdafedae
4
+ data.tar.gz: 61dcc78cd1df431803da648fe1e8339177cda22c6a08106acf232b841d2999d3
5
+ SHA512:
6
+ metadata.gz: b43b6478129e0b0cc681c12e8c915ee11624535eab59e7a9d05fc79327e38761933f51b1f0ba93172c2ff9eacbb38ffce08a2f1443c8e0fd67a491c33ec5efe1
7
+ data.tar.gz: 68932bbba683ef5e6df0096249a483b6f9f9802bd8cf2f43340da93bf69a5ed48ae512ee924ebd6a5eb95e29ecd0b40520f202be1c75a6e3b6b7b9faa2675f91
@@ -0,0 +1,229 @@
1
+ # Cep Calculator
2
+ class CepC
3
+ require 'cep_coinbase'
4
+
5
+ attr_writer :exchange_values
6
+
7
+ def initialize(params={})
8
+ @curr_type = params.fetch(:currency_type, 'ETH')
9
+ @daily_earn = params.fetch(:daily_earn, 0.0)
10
+ @pay_limit = params.fetch(:pay_limit, 1.0)
11
+ @pool_amount = params.fetch(:pool_amount, 0.0)
12
+ @prices = params.fetch(:prices, {})
13
+ @exchange_values = params.fetch(:exchange_values, [['USD', '$']])
14
+
15
+ get_currencies
16
+ rescue
17
+ return -1
18
+ end
19
+
20
+ def exchange_diff(curr1,curr2,printable=false)
21
+ diff = price_of(curr1) / price_of(curr2)
22
+
23
+ return diff unless printable
24
+
25
+ diff_str = "#{curr1} / #{curr2}"
26
+ print_header 'CURRENCY(' + diff_str + ')'
27
+ printf "%s currency: %.4f\n", diff_str, diff
28
+ puts
29
+
30
+ return diff
31
+ rescue
32
+ return -1
33
+ end
34
+
35
+ def price_of(currency)
36
+ price = @exchanges[currency.upcase]
37
+ (price.nil?) ? raise : price.to_f
38
+ rescue
39
+ puts 'Currency does not exist!'
40
+ # raise
41
+ return -1
42
+ end
43
+
44
+ def amount_of(currency,amount,printable=false)
45
+ price = price_of(currency) * amount
46
+
47
+ return price unless printable
48
+
49
+ printf "%s: %.2f %s\n",
50
+ curr, price, curr_sym
51
+ price
52
+ rescue
53
+ false
54
+ end
55
+
56
+ def print_exchange_amounts(arr=@exchange_values)
57
+ print_header " #{total_amount} #{@curr_type} EXCHANGE AMOUNTs"
58
+
59
+ arr.each { |curr, curr_sym| amount_of(curr, curr_sym, true) }
60
+
61
+ true
62
+ rescue
63
+ false
64
+ end
65
+
66
+ def print_params
67
+ print_header "PARAMETERS"
68
+ printf "%s: %f\n",'Daily Earn ', @daily_earn
69
+ printf "%s: %f\n",'Pay Limit ', @pay_limit
70
+ printf "%s: %f\n",'Pool Amount', @pool_amount
71
+ puts
72
+ end
73
+
74
+ def print_owned_amounts(arr=@exchange_values)
75
+ print_header "#{total_amount} #{@curr_type} DETAILED AMOUNTs"
76
+
77
+ print_owned_exchange_amounts
78
+ puts
79
+
80
+ arr.each do |curr, curr_sym|
81
+ print_owned_amount_of(curr, curr_sym)
82
+ puts
83
+ end
84
+
85
+ true
86
+ rescue
87
+ false
88
+ end
89
+
90
+ def print_prices(arr=@exchange_values)
91
+ print_header "1 #{@curr_type} PRICEs"
92
+ arr.each do |curr, curr_sym|
93
+ print_price(curr, curr_sym)
94
+ end
95
+ puts
96
+
97
+ true
98
+ rescue
99
+ false
100
+ end
101
+
102
+ def print_n_day_earned(n = 1, curr_arr = @exchange_values)
103
+ print_header "#{n} DAYs EARNING"
104
+
105
+ curr_arr.each do |curr, curr_sym|
106
+ print_n_day_earning(n, curr, curr_sym)
107
+ end
108
+
109
+ puts
110
+ end
111
+
112
+ def print_day_left
113
+ print_header "Mining Estimation"
114
+ if @daily_earn <= 0.0
115
+ puts "Your daily earn is #{@daily_earn}. You will never reached the limit!!!"
116
+ return false
117
+ end
118
+
119
+ day_left = (@pay_limit - @pool_amount)/@daily_earn
120
+
121
+ if day_left <= 0.0
122
+ printf "%d day left to payout! Please check your wallet.", absolute_day
123
+ return true
124
+ end
125
+
126
+ absolute_day = day_left.ceil
127
+
128
+ complete_perc = (@pool_amount / @pay_limit) * 100
129
+ if complete_perc <= 100.0 && complete_perc > 0.0
130
+ printf "%% %.2f completed!\n", complete_perc
131
+ end
132
+
133
+ printf "%d(%.2f) day left to payout!\n",
134
+ absolute_day, day_left
135
+ puts "Estimated day: #{Date.today+absolute_day}"
136
+ puts
137
+
138
+ return true
139
+ rescue
140
+ false
141
+ end
142
+
143
+ private
144
+
145
+ def daily_earn(de = false)
146
+ @daily_earn = (de) ? de.to_f : @daily_earn
147
+ end
148
+
149
+ def total_amount
150
+ @prices.values.inject(0.0) { |sum, v| sum +v}
151
+ end
152
+
153
+ def get_currencies
154
+ exchange_obj = CEP_COINBASE.new(
155
+ currency_type: @curr_type
156
+ )
157
+ exchange_obj.fetch
158
+ # exchange_obj.cache
159
+ # exchange_obj.rename_param
160
+ exchange_obj.process
161
+ @exchanges = exchange_obj.exchanges
162
+
163
+ unless @exchanges
164
+ throw 'Exchanges could not be fetched'
165
+ end
166
+ rescue => e
167
+ throw e
168
+ end
169
+
170
+ def print_owned_amount_of(curr, curr_sym='')
171
+ total_price = amount_of(curr, total_amount)
172
+
173
+ printf "%s: %.2f: %s\n",
174
+ curr, total_price, curr_sym
175
+
176
+ @prices.each do |name, amount|
177
+ price = amount_of(curr, amount)
178
+ printf "-->%8s: %.2f %s\n",
179
+ name, price, curr_sym
180
+ end
181
+ end
182
+
183
+ def print_owned_exchange_amounts
184
+ total_price = @prices.values.inject(:+)
185
+
186
+ printf "Total: %.8f %s\n",total_price,@curr_type
187
+
188
+ @prices.each do |name, amount|
189
+ printf "-->%8s: %.8f %s\n",
190
+ name, amount,@curr_type
191
+ end
192
+ end
193
+
194
+ def print_daily_earning(curr, curr_sym='')
195
+ earn = price_of(curr) * @daily_earn
196
+ printf "%s: %.4f %s\n", curr, earn, curr_sym
197
+ end
198
+
199
+ def print_n_day_earning(n, curr, curr_sym='')
200
+ earn = n * price_of(curr) * @daily_earn
201
+ printf "%s: %.4f %s\n", curr, earn, curr_sym
202
+ end
203
+
204
+ def print_price(curr, curr_sym='')
205
+ printf "%s: %.4f %s\n", curr, price_of(curr), curr_sym
206
+ end
207
+
208
+ def print_big_header(str)
209
+ print_head_format str, '='
210
+ puts
211
+ end
212
+
213
+ def print_header(str)
214
+ print_head_format str, '-'
215
+ puts
216
+ end
217
+
218
+ def print_head_format(str, deli='-')
219
+ len = str.size
220
+ scr_chr_len = 48
221
+
222
+ deli_limit = scr_chr_len - len
223
+ deli_limit = (deli_limit > 10) ? (deli_limit/2.0).floor : 5
224
+
225
+ deli_limit.times { print deli }
226
+ print '# ' + str + ' #'
227
+ deli_limit.times { print deli }
228
+ end
229
+ end
metadata ADDED
@@ -0,0 +1,60 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cepc_coinbase
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.6
5
+ platform: ruby
6
+ authors:
7
+ - tayak
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-08-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: cep_coinbase
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.1.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.1.1
27
+ description: CepC is a mining estimation and coin ratio calculator and demonstrator.
28
+ CepC basicly calculation and print class for mining rigs. Not to be confused with
29
+ the demon-strator.
30
+ email: yasir.kiroglu@gmail.com
31
+ executables: []
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - lib/cepc_coinbase.rb
36
+ homepage: https://github.com/taiak/cepc
37
+ licenses:
38
+ - Apache-2.0
39
+ metadata: {}
40
+ post_install_message:
41
+ rdoc_options: []
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ requirements: []
55
+ rubygems_version: 3.2.29
56
+ signing_key:
57
+ specification_version: 4
58
+ summary: CEP Calculator which use CEP class to fetch and process coin prices to print
59
+ as formated string.
60
+ test_files: []