tvdb2 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 24469dc02a86ad88f6ea8383a9dced2cff7743d7
4
- data.tar.gz: 47bd77a6f6a72891d0f4104a9c2f9b6295ae2681
3
+ metadata.gz: 35acac1f19d387fe8bb928969a6d5b136b550eec
4
+ data.tar.gz: 8b659ccbe41cacf0a45b790cb6fc266f01ae796c
5
5
  SHA512:
6
- metadata.gz: 1fc56697b7e19c29835735c0ae75a2ff8a503f8d30c816bf46991d7ba3737cead0b1c96472c10fafe296a15e744122b3a2596deaa62be2c75658cb7a0e6687ff
7
- data.tar.gz: cc1c1e3cd58c5dcdb8911a2fe3d833bee8445515cb383ad11eaab6618b43541aa79eb112a1cbb8f2ba87b2fc6f9a172d5a955d40ad8546ff3ca2750f9246d384
6
+ metadata.gz: 2c5ecad7942fcba9300e5329361c9b104de5093ce18afbdc9082552154a2124cb4d0c9c5b4fb81dbc520386e88f86c9f55ebcbc12e6f0701eb27b0538cd143ba
7
+ data.tar.gz: 49f11f181082b805ca7141da68872c89244241ef766d1fd1dbb60bfb2cb9e80351c3a360f96c3f04ecaa74ea0dab933a9bf7ab1227da5538cf51543b490577da
data/lib/tvdb2/episode.rb CHANGED
@@ -79,6 +79,19 @@ module Tvdb2
79
79
  "#{self.airedSeason}x#{self.airedEpisodeNumber}"
80
80
  end
81
81
 
82
+ # @param [Boolean] retrieve_all_fields if true retrieve all fields
83
+ # (from api) of the episode.
84
+ # @return [Hash] the episode to hash.
85
+ def to_h(retrieve_all_fields: false)
86
+ get_all_fields! if retrieve_all_fields
87
+ hash = {}
88
+ FIELDS.each do |field|
89
+ hash[field.to_sym] = instance_variable_get("@#{field}")
90
+ end
91
+ hash[:name] = @episodeName
92
+ return hash
93
+ end
94
+
82
95
  private
83
96
 
84
97
  # Get all data fields for this episode. Calling api endpoint `GET
data/lib/tvdb2/series.rb CHANGED
@@ -74,6 +74,7 @@ module Tvdb2
74
74
  def series_summary
75
75
  @client.series_summary(self.id)
76
76
  end
77
+ alias_method :summary, :series_summary
77
78
 
78
79
  # Retrieve the episodes of the series.
79
80
  #
@@ -206,6 +207,24 @@ module Tvdb2
206
207
 
207
208
  # @!endgroup
208
209
 
210
+ # @param [Boolean] episodes if true include all episodes
211
+ # ({Episode#to_h}) on the hash.
212
+ # @param [Boolean] retrieve_all_fields if true retrieve all fields
213
+ # (from api) of the series.
214
+ # @return [Hash] the series to hash.
215
+ def to_h(episodes: false, retrieve_all_fields: false)
216
+ get_all_fields! if retrieve_all_fields
217
+ hash = {}
218
+ FIELDS.each do |field|
219
+ hash[field.to_sym] = instance_variable_get("@#{field}")
220
+ end
221
+ hash[:name] = @seriesName
222
+ hash[:poster_url] = self.poster_url
223
+ hash[:banner_url] = self.banner_url
224
+ hash[:episodes] = self.episodes.map(&:to_h) if episodes
225
+ return hash
226
+ end
227
+
209
228
  private
210
229
 
211
230
  # Get all data fields for this series. Calling api endpoint `GET
data/lib/tvdb2/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Tvdb2
2
2
  # The library version.
3
- VERSION = '0.1.1'
3
+ VERSION = '0.1.2'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tvdb2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - pioz
@@ -102,7 +102,6 @@ files:
102
102
  - lib/tvdb2/series.rb
103
103
  - lib/tvdb2/tvdb_struct.rb
104
104
  - lib/tvdb2/version.rb
105
- - test.rb
106
105
  - tvdb2.gemspec
107
106
  homepage: https://github.com/pioz/tvdb2
108
107
  licenses:
data/test.rb DELETED
@@ -1,9 +0,0 @@
1
- module Ciccio
2
-
3
- def pluto
4
- puts 'ciccio'
5
- end
6
-
7
- end
8
-
9
- Ciccio.pluto