mega_lotto_ps 0.3.0 → 0.4.0
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.
- checksums.yaml +4 -4
- data/exe/mega-lotto +9 -0
- data/lib/mega_lotto_ps.rb +2 -0
- data/lib/mega_lotto_ps/report.rb +18 -0
- data/lib/mega_lotto_ps/version.rb +1 -1
- metadata +3 -3
- data/lib/mega_lotto_ps/.version.rb.swp +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 728d9012c3bd74c27a7443f965fff0bb96eaca7a
|
|
4
|
+
data.tar.gz: 9c112a9e8dc7821294b7da5ee2b3052045aef33d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 186bd869a6bfb9d8e850ef75023e33bf39f35aa13f8c5093e172eb7fa2da74b52cf1ed4dd0f5217274b7151bebdf0762c244ed623b9629f30f256d06dc1df22b
|
|
7
|
+
data.tar.gz: 43aed5185af90b21b94eadf202d3edd199a1720664bb0b55255fb03071b503cd3f184394ccbe8f54e5b971986f2420855bbc88702ea2dd8e61f538c4fe1146bd
|
data/exe/mega-lotto
CHANGED
|
@@ -3,6 +3,15 @@
|
|
|
3
3
|
require "bundler/setup"
|
|
4
4
|
require "mega_lotto_ps"
|
|
5
5
|
require_relative "../lib/mega_lotto_ps/drawing"
|
|
6
|
+
require_relative "../lib/mega_lotto_ps/report"
|
|
6
7
|
|
|
7
8
|
drawing = MegaLottoPs::Drawing.new.draw
|
|
8
9
|
puts drawing
|
|
10
|
+
|
|
11
|
+
ledger = [ [ "Deposit Check #123", 500.15],
|
|
12
|
+
["Fancy Shoes", -200.25],
|
|
13
|
+
["Fancy Hat", -54.40],
|
|
14
|
+
["ATM Deposit", 1200.00],
|
|
15
|
+
["Kitten Litteh", -5.00] ]
|
|
16
|
+
report = Report.new(ledger)
|
|
17
|
+
puts report.formatted_output
|
data/lib/mega_lotto_ps.rb
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
class Report
|
|
2
|
+
def initialize(ledger)
|
|
3
|
+
@balance = ledger.inject(0) { |sum, (k,v)| sum + v }
|
|
4
|
+
@credits, @debits = ledger.partition { |k,v| v > 0 }
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
attr_reader :credits, :debits, :balance
|
|
8
|
+
|
|
9
|
+
def formatted_output
|
|
10
|
+
"Current Balance: #{balance}\n\n" +
|
|
11
|
+
"Credits:\n\n#{formatted_line_items(credits)}\n\n" +
|
|
12
|
+
"Debits:\n\n#{formatted_line_items(debits)}"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def formatted_line_items(items)
|
|
16
|
+
items.map { |k, v| "#{k}: #{'%.2f' % v.abs}" }.join("\n")
|
|
17
|
+
end
|
|
18
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mega_lotto_ps
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Prarthana Shiva
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-05-
|
|
11
|
+
date: 2017-05-12 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -86,8 +86,8 @@ files:
|
|
|
86
86
|
- bin/setup
|
|
87
87
|
- exe/mega-lotto
|
|
88
88
|
- lib/mega_lotto_ps.rb
|
|
89
|
-
- lib/mega_lotto_ps/.version.rb.swp
|
|
90
89
|
- lib/mega_lotto_ps/drawing.rb
|
|
90
|
+
- lib/mega_lotto_ps/report.rb
|
|
91
91
|
- lib/mega_lotto_ps/version.rb
|
|
92
92
|
- mega_lotto_ps.gemspec
|
|
93
93
|
homepage: https://github.com/prarthanashiva15/mega_lotto_ps
|
|
Binary file
|