Class: Yt::Models::PolicyRule
- Inherits:
-
Object
- Object
- Yt::Models::PolicyRule
- Defined in:
- lib/yt/models/policy_rule.rb
Overview
Provides methods to interact with YouTube ContentID policy rules. Rules that specify the action that YouTube should take and may optionally specify the conditions under which that action is enforced.
Constant Summary collapse
- ACTIONS =
%q(block monetize takedown track)
Instance Method Summary collapse
-
#action ⇒ String
Return the policy that YouTube should enforce if the rule’s conditions are all valid for an asset or for an attempt to view that asset on YouTube.
-
#excluded_territories ⇒ Array<String>
Return the list of territories where the policy does not apply.
-
#included_territories ⇒ Array<String>
Return the list of territories where the policy applies.
-
#initialize(options = {}) ⇒ PolicyRule
constructor
A new instance of PolicyRule.
-
#match_duration ⇒ Array<Hash<Symbol, Float>>
The intervals of time the user- or partner-uploaded content needs to match a reference file for the rule to apply.
-
#match_percent ⇒ Array<Hash<Symbol, Float>>
The intervals of percentages the user- or partner-uploaded content needs to match a reference file for the rule to apply.
-
#reference_duration ⇒ Array<Hash<Symbol, Float>>
The intervals of duration that the reference must have for the rule to apply.
-
#reference_percent ⇒ Array<Hash<Symbol, Float>>
The intervals of percentages the reference file needs to match the user- or partner-uploaded content for the rule to apply.
-
#subaction ⇒ Array
A list of additional actions that YouTube should take if the conditions in the rule are met.
Constructor Details
#initialize(options = {}) ⇒ PolicyRule
Returns a new instance of PolicyRule.
10 11 12 |
# File 'lib/yt/models/policy_rule.rb', line 10 def initialize( = {}) @data = [:data] end |
Instance Method Details
#action ⇒ String
Return the policy that YouTube should enforce if the rule’s conditions are all valid for an asset or for an attempt to view that asset on YouTube. Valid values for this property are: block, monetize, takedown, track.
21 22 23 |
# File 'lib/yt/models/policy_rule.rb', line 21 def action @action ||= @data['action'] end |
#excluded_territories ⇒ Array<String>
Return the list of territories where the policy does not apply. Each territory is an ISO 3166 two-letter country code. YouTube determines whether the condition is satisfied based on the user’s location.
50 51 52 |
# File 'lib/yt/models/policy_rule.rb', line 50 def excluded_territories territories_type == 'exclude' ? territories : [] end |
#included_territories ⇒ Array<String>
Return the list of territories where the policy applies. Each territory is an ISO 3166 two-letter country code. YouTube determines whether the condition is satisfied based on the user’s location.
39 40 41 |
# File 'lib/yt/models/policy_rule.rb', line 39 def included_territories territories_type == 'include' ? territories : [] end |
#match_duration ⇒ Array<Hash<Symbol, Float>>
Returns the intervals of time the user- or partner-uploaded content needs to match a reference file for the rule to apply. :low is the minimum (inclusive) allowed value and :high is the maximum (inclusive) allowed value for the rule to apply.
60 61 62 |
# File 'lib/yt/models/policy_rule.rb', line 60 def match_duration @match_duration ||= match_duration_list.map{|r| low_and_high r} end |
#match_percent ⇒ Array<Hash<Symbol, Float>>
Returns the intervals of percentages the user- or partner-uploaded content needs to match a reference file for the rule to apply. :low is the minimum (inclusive) allowed value and :high is the maximum (inclusive) allowed value for the rule to apply.
70 71 72 |
# File 'lib/yt/models/policy_rule.rb', line 70 def match_percent @match_percent ||= match_percent_list.map{|r| low_and_high r} end |
#reference_duration ⇒ Array<Hash<Symbol, Float>>
Returns the intervals of duration that the reference must have for the rule to apply. :low is the minimum (inclusive) allowed value, :high is the maximum (inclusive) allowed value for the rule to apply.
80 81 82 |
# File 'lib/yt/models/policy_rule.rb', line 80 def reference_duration @reference_duration ||= reference_duration_list.map{|r| low_and_high r} end |
#reference_percent ⇒ Array<Hash<Symbol, Float>>
Returns the intervals of percentages the reference file needs to match the user- or partner-uploaded content for the rule to apply. :low is the minimum (inclusive) allowed value, :high is the maximum (inclusive) allowed value for the rule to apply.
90 91 92 |
# File 'lib/yt/models/policy_rule.rb', line 90 def reference_percent @reference_percent ||= reference_percent_list.map{|r| low_and_high r} end |
#subaction ⇒ Array
Returns A list of additional actions that YouTube should take if the conditions in the rule are met. Valid values for this property are: review.
28 29 30 |
# File 'lib/yt/models/policy_rule.rb', line 28 def subaction @subaction ||= @data['subaction'] end |