Class: Yt::Models::PolicyRule

Inherits:
Base
  • Object
show all
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

Methods included from Associations::HasReports

#has_report

Methods included from Associations::HasViewerPercentages

#has_viewer_percentages

Methods included from Associations::HasOne

#has_one

Methods included from Associations::HasMany

#has_many

Methods included from Associations::HasAuthentication

#has_authentication

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(options = {})
  @data = options[:data]
end

Instance Method Details

#actionString

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.

Returns:

  • (String)

    the policy that YouTube should enforce.



21
# File 'lib/yt/models/policy_rule.rb', line 21

has_attribute :action

#excluded_territoriesArray<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.

Examples:

(with ‘block’ action) only allow U.S. users to view a video:

excluded_territories #=> ['us']

Returns:

  • (Array<String>)

    the territories where the policy does not apply.



46
47
48
# File 'lib/yt/models/policy_rule.rb', line 46

def excluded_territories
  territories_type == 'exclude' ? territories : []
end

#included_territoriesArray<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.

Examples:

(with ‘block’ action) only block a video for U.S. users:

included_territories #=> ['us']

Returns:

  • (Array<String>)

    the territories where the policy applies.



35
36
37
# File 'lib/yt/models/policy_rule.rb', line 35

def included_territories
  territories_type == 'include' ? territories : []
end

#match_durationArray<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.

Examples:

videos that match the reference for 20 to 30 seconds:

match_duration #= [{low: 20.0, high: 30.0}]

Returns:

  • (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. :low is the minimum (inclusive) allowed value and :high is the maximum (inclusive) allowed value for the rule to apply.



56
57
58
# File 'lib/yt/models/policy_rule.rb', line 56

def match_duration
  match_duration_list.map{|r| low_and_high r}
end

#match_percentArray<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.

Examples:

videos that match the reference for 40%~50% of their duration:

match_percent #= [{low: 40.0, high: 50.0}]

Returns:

  • (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. :low is the minimum (inclusive) allowed value and :high is the maximum (inclusive) allowed value for the rule to apply.



66
67
68
# File 'lib/yt/models/policy_rule.rb', line 66

def match_percent
  match_percent_list.map{|r| low_and_high r}
end

#reference_durationArray<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.

Examples:

references that are between 20 and 30 seconds:

reference_duration #= [{low: 20.0, high: 30.0}]

Returns:

  • (Array<Hash<Symbol, Float>>)

    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.



76
77
78
# File 'lib/yt/models/policy_rule.rb', line 76

def reference_duration
  reference_duration_list.map{|r| low_and_high r}
end

#reference_percentArray<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.

Examples:

videos that match either 0%~10% or 40%~50% of a reference:

reference_percent #= [{low: 0.0, high: 10.0}, {low: 40.0, high: 50.0}]

Returns:

  • (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. :low is the minimum (inclusive) allowed value, :high is the maximum (inclusive) allowed value for the rule to apply.



86
87
88
# File 'lib/yt/models/policy_rule.rb', line 86

def reference_percent
  reference_percent_list.map{|r| low_and_high r}
end

#subactionArray

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.

Returns:

  • (Array)

    A list of additional actions that YouTube should take if the conditions in the rule are met. Valid values for this property are: review.



26
# File 'lib/yt/models/policy_rule.rb', line 26

has_attribute :subaction