Class: XxxRename::ActorsHelper
- Inherits:
-
Object
- Object
- XxxRename::ActorsHelper
- Includes:
- Singleton
- Defined in:
- lib/xxx_rename/actors_helper.rb
Instance Method Summary collapse
- #append_female(actor_hash) ⇒ Object
- #append_male(actor_hash) ⇒ Object
- #auto_fetch(actor) ⇒ Object
- #auto_fetch!(actor) ⇒ Object
- #female?(actor) ⇒ Boolean
- #female_actors ⇒ Object
- #male?(actor) ⇒ Boolean
- #male_actors ⇒ Object
- #matcher(matcher = nil) ⇒ Object
- #processed!(actor) ⇒ Object
- #processed?(actor) ⇒ Boolean
Instance Method Details
#append_female(actor_hash) ⇒ Object
23 24 25 |
# File 'lib/xxx_rename/actors_helper.rb', line 23 def append_female(actor_hash) female_actors[actor_hash["compressed_name"]] = actor_hash["name"] if female_actors[actor_hash["compressed_name"]].nil? end |
#append_male(actor_hash) ⇒ Object
27 28 29 |
# File 'lib/xxx_rename/actors_helper.rb', line 27 def append_male(actor_hash) male_actors[actor_hash["compressed_name"]] = actor_hash["name"] if male_actors[actor_hash["compressed_name"]].nil? end |
#auto_fetch(actor) ⇒ Object
66 67 68 69 70 71 |
# File 'lib/xxx_rename/actors_helper.rb', line 66 def auto_fetch(actor) auto_fetch!(actor) rescue Errors::UnprocessedEntity => e XxxRename.logger.warn "Unable to fetch details for #{e.}" nil end |
#auto_fetch!(actor) ⇒ Object
57 58 59 60 61 62 63 64 |
# File 'lib/xxx_rename/actors_helper.rb', line 57 def auto_fetch!(actor) details = fetch_actor_details.details(actor) raise Errors::UnprocessedEntity, actor if details.nil? details["gender"].downcase == "female" ? append_female(details) : append_male(details) nil end |
#female?(actor) ⇒ Boolean
38 39 40 41 42 43 |
# File 'lib/xxx_rename/actors_helper.rb', line 38 def female?(actor) processed!(actor) female_actors.key? actor.normalize rescue Errors::UnprocessedEntity false end |
#female_actors ⇒ Object
15 16 17 |
# File 'lib/xxx_rename/actors_helper.rb', line 15 def female_actors @female_actors ||= {} end |
#male?(actor) ⇒ Boolean
31 32 33 34 35 36 |
# File 'lib/xxx_rename/actors_helper.rb', line 31 def male?(actor) processed!(actor) male_actors.key? actor.normalize rescue Errors::UnprocessedEntity false end |
#male_actors ⇒ Object
19 20 21 |
# File 'lib/xxx_rename/actors_helper.rb', line 19 def male_actors @male_actors ||= {} end |
#matcher(matcher = nil) ⇒ Object
9 10 11 12 13 |
# File 'lib/xxx_rename/actors_helper.rb', line 9 def matcher(matcher = nil) raise Errors::FatalError, "#{self.class.name} initialised without matcher" if @matcher.nil? && matcher.nil? @matcher ||= matcher end |
#processed!(actor) ⇒ Object
51 52 53 54 55 |
# File 'lib/xxx_rename/actors_helper.rb', line 51 def processed!(actor) return true if female_actors.key?(actor.normalize) || male_actors.key?(actor.normalize) raise Errors::UnprocessedEntity, actor end |
#processed?(actor) ⇒ Boolean
45 46 47 48 49 |
# File 'lib/xxx_rename/actors_helper.rb', line 45 def processed?(actor) processed!(actor) rescue Errors::UnprocessedEntity false end |