Class: WhereTo::Locator
- Inherits:
-
Object
- Object
- WhereTo::Locator
- Defined in:
- lib/where_to/locator.rb
Instance Attribute Summary collapse
-
#airdate ⇒ Object
Returns the value of attribute airdate.
-
#episode_extension ⇒ Object
Returns the value of attribute episode_extension.
-
#episode_number ⇒ Object
Returns the value of attribute episode_number.
-
#episode_quality ⇒ Object
Returns the value of attribute episode_quality.
-
#episode_title ⇒ Object
Returns the value of attribute episode_title.
-
#group ⇒ Object
Returns the value of attribute group.
-
#season ⇒ Object
Returns the value of attribute season.
-
#season_airdate ⇒ Object
Returns the value of attribute season_airdate.
-
#series_id ⇒ Object
Returns the value of attribute series_id.
-
#series_title ⇒ Object
Returns the value of attribute series_title.
Instance Method Summary collapse
-
#initialize(hash = {}) ⇒ Locator
constructor
A new instance of Locator.
- #locate(hash = {}) ⇒ Object
- #lookup! ⇒ Object
- #params ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize(hash = {}) ⇒ Locator
Returns a new instance of Locator.
10 11 12 13 14 15 |
# File 'lib/where_to/locator.rb', line 10 def initialize(hash = {}) load_values_from hash if series_id @series_title = WhereTo::TVDB.new(params).lookup_series(series_id).name end end |
Instance Attribute Details
#airdate ⇒ Object
Returns the value of attribute airdate.
7 8 9 |
# File 'lib/where_to/locator.rb', line 7 def airdate @airdate end |
#episode_extension ⇒ Object
Returns the value of attribute episode_extension.
8 9 10 |
# File 'lib/where_to/locator.rb', line 8 def episode_extension @episode_extension end |
#episode_number ⇒ Object
Returns the value of attribute episode_number.
8 9 10 |
# File 'lib/where_to/locator.rb', line 8 def episode_number @episode_number end |
#episode_quality ⇒ Object
Returns the value of attribute episode_quality.
8 9 10 |
# File 'lib/where_to/locator.rb', line 8 def episode_quality @episode_quality end |
#episode_title ⇒ Object
Returns the value of attribute episode_title.
8 9 10 |
# File 'lib/where_to/locator.rb', line 8 def episode_title @episode_title end |
#group ⇒ Object
Returns the value of attribute group.
8 9 10 |
# File 'lib/where_to/locator.rb', line 8 def group @group end |
#season ⇒ Object
Returns the value of attribute season.
7 8 9 |
# File 'lib/where_to/locator.rb', line 7 def season @season end |
#season_airdate ⇒ Object
Returns the value of attribute season_airdate.
7 8 9 |
# File 'lib/where_to/locator.rb', line 7 def season_airdate @season_airdate end |
#series_id ⇒ Object
Returns the value of attribute series_id.
8 9 10 |
# File 'lib/where_to/locator.rb', line 8 def series_id @series_id end |
#series_title ⇒ Object
Returns the value of attribute series_title.
7 8 9 |
# File 'lib/where_to/locator.rb', line 7 def series_title @series_title end |
Instance Method Details
#locate(hash = {}) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/where_to/locator.rb', line 17 def locate(hash = {}) load_values_from hash validate! output = WhereTo.configuration.folder_format output.gsub! '%series_title', series_title output.gsub! '%season_number', season.to_s output.gsub! '%season_airdate', season_airdate.to_s if episode_title and episode_number formatter = WhereTo::EpisodeFormatter.new params output << formatter.format! end WhereTo::Location.new output end |
#lookup! ⇒ Object
40 41 42 43 |
# File 'lib/where_to/locator.rb', line 40 def lookup! tvdb = WhereTo::TVDB.new params load_values_from tvdb.lookup! end |
#params ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/where_to/locator.rb', line 45 def params _params = {} _params[:series_title] = series_title _params[:season_number] = season _params[:episode_title] = episode_title _params[:episode_number] = episode_number _params[:quality] = episode_quality _params[:extension] = episode_extension _params[:group] = group _params[:series_id] = series_id _params end |
#validate! ⇒ Object
34 35 36 37 38 |
# File 'lib/where_to/locator.rb', line 34 def validate! raise 'A season airdate is required to locate an episode' if season_airdate == nil raise 'A season number is required to locate an episode' if season.nil? true end |