nerd_log 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MWVhMDBkZjNkOTIyOTBkNzA3Njc3NGM0YTk5YzUwNTc4ZWNmMzNmNw==
4
+ YzhlNzIxNWY4ZjkzNjBlOGZhNDk3OTliOWExYThlZTk4ZDIzM2FlMw==
5
5
  data.tar.gz: !binary |-
6
- NzY5YjkzOTI2MWJjM2NmNmM4NzY5YzY1YzhiOWRjYmM3OWVhNDNkZg==
6
+ Zjc2YWZlZjVmYTQzOWU0OWJjNTU0OTQ4OTMxZGYyMTg0NDU2YzkyYQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZDcxZWJkNmM3Y2Q1Njg1MjhiMzEyZTUyNTU5ZTdkODc3ZTY3Y2NjYmQxZGJj
10
- ZjE1YWI1ZjUxMTg0Mjg3NTNmOTVjNDNmOGRlM2YwZTg4NDVjOGIxODcxNmI1
11
- OGY1MTA0ODBkOWVlY2ZjYjFlYWUzODVlYzA2ZDAzZjBkZTU1MmU=
9
+ MjNkODQyMjk5NWM0NWIxM2ZlODkxZTY0ZWE2ZTI3ZGYyODIzYjUzM2IyOTEz
10
+ NTAxZmMyODJmODgwMGQwZDJhZGU2NmI2MzE2MGRhZTQ2Zjg1YjUwNjVkMmFl
11
+ OTBiZDY4MWU1YzU0ZjcwYTZhMTI3MDIxN2NmMmE5YzI0YTRmMzk=
12
12
  data.tar.gz: !binary |-
13
- NDdhNjQyYTUwYjQ3YWY4OGZkYjdmODE4NGU2MTJkZGNlYjhhNGZkNmU1NjQ5
14
- MGFkZTdjOTU5NGQwODc5YzFhMjQzOTg0NDVkYTg4ZTE0ODBlOGYzODRiMDdj
15
- ZmU1MGZlNWYzMzg1MDg4OTdkNWFiODc4NjE1YjVhMWZhNWRjOTI=
13
+ YWExYzYzZTIxYzc4YzkzMzkwNWQ2NzkyZDU3MGE2NTExNWJjYTdlZmUzMjll
14
+ NTc3MzkzMjYyNWFiYmVhNzc5M2IzNjU3ZmRlNjU1MTc5MDAzMTE2MjFhMDg4
15
+ OTBmZjc3ZDQzMDNjNzgyYTE2OTUxODRmODg5OTFiMzMzMGM1ZGI=
@@ -0,0 +1,39 @@
1
+ require 'ostruct'
2
+
3
+ module NerdLog
4
+ class Fight
5
+ attr_reader :report_id, :http_connection
6
+ def initialize(options = {})
7
+ @report_id = options.fetch(:report_id)
8
+ @http_connection = options.fetch(:http_connection, NerdLog.configuration.http_connection)
9
+ end
10
+
11
+ def kills
12
+ @kills ||= fights.select {|f| f.kill == true }
13
+ end
14
+
15
+ def attempts
16
+ @attempts ||= fights.select {|f| f.kill == false }
17
+ end
18
+
19
+ def fights
20
+ unless @fights
21
+ raw_fights = fetch.body['fights'].select {|f| f['boss'] != 0}
22
+ @fights = []
23
+
24
+ raw_fights.each do |raw_fight|
25
+ @fights << OpenStruct.new(id: raw_fight['boss'],
26
+ kill: raw_fight['kill'],
27
+ difficulty: raw_fight['difficulty'])
28
+ end
29
+ end
30
+ @fights
31
+ end
32
+
33
+ def fetch
34
+ response = http_connection.get("report/fights/#{report_id}")
35
+
36
+ response
37
+ end
38
+ end
39
+ end
@@ -1,3 +1,3 @@
1
1
  module NerdLog
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
data/lib/nerd_log.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require "nerd_log/version"
2
2
  require "nerd_log/report"
3
3
  require "nerd_log/encounter"
4
+ require "nerd_log/fight"
4
5
  require "faraday_middleware"
5
6
 
6
7
  module NerdLog
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nerd_log
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Robertson
@@ -80,6 +80,7 @@ files:
80
80
  - Rakefile
81
81
  - lib/nerd_log.rb
82
82
  - lib/nerd_log/encounter.rb
83
+ - lib/nerd_log/fight.rb
83
84
  - lib/nerd_log/report.rb
84
85
  - lib/nerd_log/version.rb
85
86
  - nerd_log.gemspec