Class: TrailerVote::MediaTypes::AudioFragment

Inherits:
BaseText
  • Object
show all
Defined in:
lib/trailer_vote/media_types/audio_fragment.rb

Overview

Media Types for Audio Fragments

Audio Fragments are recognizable using FingerprintBinary. It might be an advertisement, a trailer or a sound bite. They belong to a Product. Audio fragments are used for recognition, e.g. showing an advertisement when it’s recognised, and used for feedback, i.e. a requirement to record and store Feedback.

Instance Method Summary collapse

Methods inherited from BaseText

organisation

Instance Method Details

#to_constructable::MediaTypes::Constructable

Returns the construtable media type

Returns:

  • (::MediaTypes::Constructable)

    a constructable

See Also:



25
# File 'lib/trailer_vote/media_types/audio_fragment.rb', line 25

use_name 'audio_fragment'

#valid?(data, constructed_media_type, **opts) ⇒ TrueClass, FalseClass

Validates the data against the validation for constructed_media_type.

Parameters:

  • data (Object)

    the data to validate

  • constructed_media_type (Constructable, String)

    something that resolved into a media type with validations

  • opts (Hash)

    passed on to MediaTypes::Scheme#valid?

Returns:

  • (TrueClass, FalseClass)

    true if valid, false otherwise

See Also:



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/trailer_vote/media_types/audio_fragment.rb', line 53

validations do
  version 1 do
    version_1_base = ::MediaTypes::Scheme.new do
      attribute :content_addressable, String
      attribute :expires_at, AllowNil(Types::Iso8601)

      link :self
      link :product
      link :feedback
      link :advert
      link :direct
    end

    attribute :audio_fragment do
      merge version_1_base
    end

    view 'index' do
      attribute :audio_fragments do
        collection :_index, allow_empty: true do
          attribute :href, Types::HttpUrl
          not_strict
        end

        not_strict
      end
    end

    view 'collection' do
      attribute :audio_fragments do
        collection :_embedded, version_1_base, allow_empty: true
        not_strict
      end
    end
  end
end

#validate!(data, constructed_media_type, **opts) ⇒ TrueClass

Validates the data against the validation for constructed_media_type. Raises if invalid

Parameters:

  • data (Object)

    the data to validate

  • constructed_media_type (Constructable, String)

    something that resolved into a media type with validations

  • opts (Hash)

    passed on to MediaTypes::Scheme#validate

Returns:

  • (TrueClass)

    true if valid

Raises:

  • ::MediaTypes::Scheme::ValidationError an error if the scheme is not valid

See Also:



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/trailer_vote/media_types/audio_fragment.rb', line 53

validations do
  version 1 do
    version_1_base = ::MediaTypes::Scheme.new do
      attribute :content_addressable, String
      attribute :expires_at, AllowNil(Types::Iso8601)

      link :self
      link :product
      link :feedback
      link :advert
      link :direct
    end

    attribute :audio_fragment do
      merge version_1_base
    end

    view 'index' do
      attribute :audio_fragments do
        collection :_index, allow_empty: true do
          attribute :href, Types::HttpUrl
          not_strict
        end

        not_strict
      end
    end

    view 'collection' do
      attribute :audio_fragments do
        collection :_embedded, version_1_base, allow_empty: true
        not_strict
      end
    end
  end
end