Class: OpenRosa::MediaFile
- Inherits:
-
Object
- Object
- OpenRosa::MediaFile
- Defined in:
- lib/open_rosa/media_file.rb
Overview
Represents a media file (image, audio, video, entity list) associated with a form. Media files are listed in the form's manifest and downloaded separately from the form definition.
Instance Attribute Summary collapse
-
#download_url ⇒ Object
readonly
Returns the value of attribute download_url.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#hash ⇒ Object
readonly
Returns the value of attribute hash.
-
#integrity_url ⇒ Object
readonly
Returns the value of attribute integrity_url.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(filename:, download_url:, hash: nil, file: nil, type: nil, integrity_url: nil) ⇒ MediaFile
constructor
Creates a new MediaFile.
Constructor Details
#initialize(filename:, download_url:, hash: nil, file: nil, type: nil, integrity_url: nil) ⇒ MediaFile
Creates a new MediaFile
rubocop:disable Metrics/MethodLength, Metrics/ParameterLists
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/open_rosa/media_file.rb', line 44 def initialize(filename:, download_url:, hash: nil, file: nil, type: nil, integrity_url: nil) # rubocop:enable Metrics/ParameterLists @filename = validate_filename(filename) @download_url = download_url @type = type @integrity_url = integrity_url # Hash can be provided or generated from file if hash @hash = hash elsif file @hash = generate_hash(file) else raise ArgumentError, "Either hash or file parameter must be provided" end # Validate entityList requirements validate_entity_list if type == "entityList" end |
Instance Attribute Details
#download_url ⇒ Object (readonly)
Returns the value of attribute download_url.
32 33 34 |
# File 'lib/open_rosa/media_file.rb', line 32 def download_url @download_url end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
32 33 34 |
# File 'lib/open_rosa/media_file.rb', line 32 def filename @filename end |
#hash ⇒ Object (readonly)
Returns the value of attribute hash.
32 33 34 |
# File 'lib/open_rosa/media_file.rb', line 32 def hash @hash end |
#integrity_url ⇒ Object (readonly)
Returns the value of attribute integrity_url.
32 33 34 |
# File 'lib/open_rosa/media_file.rb', line 32 def integrity_url @integrity_url end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
32 33 34 |
# File 'lib/open_rosa/media_file.rb', line 32 def type @type end |