badass 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/badass.rb +9 -0
  3. data/lib/badass/sale.rb +16 -0
  4. metadata +3 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e48b4cc6729c2e2b669be4c10796aa438da25c9b58eaee979c3d1e4dbae0f89a
4
- data.tar.gz: f8b76cd02126f0d0696b8c169cd21f832ea1c51b8a3f16d79f9d845e18e291f1
3
+ metadata.gz: 358f29f3cf11b3f9d1c2d66b61ed198111602ced25a48df875a7c369cf296a43
4
+ data.tar.gz: 9a7a254ed3196cc7edf758e4e71b312c8bb965e91f3ecbe948d22ef58fa083f8
5
5
  SHA512:
6
- metadata.gz: 468602146563064d4755dda01ecc741a28615fa22fb2be25cad2778061baebe7a29bf8cac723e62f9419172d08ce1857229d283ffd5cc576109243ae5f71cea8
7
- data.tar.gz: 857e993e52a020ea95b1f0d890a22fe8656a02514a122dfb20df8cb06a188996e058935f9f7656015d9318fb593afb8df785b6aaea68daa72f3da71c3835551f
6
+ metadata.gz: 69fd3d01fd407f4e968be3d8bcf5e36f0447d31b7287eb1be505ed10594308eb9cd98539608d2b9e767edf566e430c50ca17046958a847c39d324a7c2d221384
7
+ data.tar.gz: a98856af1ab468c4ecf29517801a426dba4d648f49132267df130643e8b584263a6da5114415264df1b254608187a54ad3ca6aa9e34d8a32c218f1b9d3dbf54f
@@ -1,5 +1,6 @@
1
1
  require 'net/http'
2
2
  require 'json'
3
+ require 'date'
3
4
 
4
5
  module BadASS
5
6
  FIRMNESSES = { '2' => 'Extra Soft', '3' => 'Soft', '5' => 'Medium', '8' => 'Firm', '3/5' => 'Soft Shaft, Med Base', '5/3' => 'Soft Shaft, Med Base', '3/8' => 'Soft Shaft, Firm Base', '8/3' => 'Soft Shaft, Firm Base', '5/8' => 'Med Shaft, Firm Base', '8/5' => 'Med Shaft, Firm Base' }.freeze
@@ -10,7 +11,15 @@ module BadASS
10
11
  @baddragon_skus[toy['sku']] = toy['name']
11
12
  end
12
13
  BAD_DRAGON_SKUS = @baddragon_skus.freeze
14
+
15
+ # Gets the current sales. Returns a hash of sales.
16
+ def self.sales
17
+ JSON.parse(Net::HTTP.get(URI('https://bad-dragon.com/api/sales'))).map do |sale|
18
+ BadASS::Sale.new(sale)
19
+ end
20
+ end
13
21
  end
14
22
 
15
23
  require 'badass/client'
16
24
  require 'badass/toy'
25
+ require 'badass/sale'
@@ -0,0 +1,16 @@
1
+ class BadASS::Sale
2
+ # Create a Sale object using a hash from the API.
3
+ def initialize(sale_hash)
4
+ @title = sale_hash['title']
5
+ @description = JSON.parse(sale_hash['content'])['blocks'].map { |x| x['text'] }.join("\n")
6
+ @image = sale_hash['image']['url']
7
+ @start_date = Date.rfc3339(sale_hash['startDate']) rescue nil
8
+ @end_date = Date.rfc3339(sale_hash['endDate']) rescue nil
9
+ end
10
+
11
+ attr_reader :title
12
+ attr_reader :description
13
+ attr_reader :image
14
+ attr_reader :start_date
15
+ attr_reader :end_date
16
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: badass
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - charagarlnad
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-18 00:00:00.000000000 Z
11
+ date: 2018-05-19 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A simple Bad Dragon Assistant Gem.
14
14
  email: ''
@@ -18,6 +18,7 @@ extra_rdoc_files: []
18
18
  files:
19
19
  - lib/badass.rb
20
20
  - lib/badass/client.rb
21
+ - lib/badass/sale.rb
21
22
  - lib/badass/toy.rb
22
23
  homepage: https://github.com/charagarlnad/badass
23
24
  licenses: