class GovukPublishingComponents::Presenters::Attachment::SupportedContentType
Constants
- TYPES
Attributes
content_type_data[R]
Public Class Methods
find(content_type, extension = nil)
click to toggle source
# File lib/govuk_publishing_components/presenters/attachment.rb, line 103 def self.find(content_type, extension = nil) matching_types = TYPES.select { |type| type[:content_type] == content_type } return UnsupportedContentType.new(content_type: content_type) if matching_types.empty? extension_match = if matching_types.length > 1 matching_types.find { |type| type[:extension] == extension } end content_type = extension_match || matching_types.first new(content_type) end
new(content_type_data)
click to toggle source
# File lib/govuk_publishing_components/presenters/attachment.rb, line 117 def initialize(content_type_data) @content_type_data = content_type_data end
Public Instance Methods
abbr()
click to toggle source
# File lib/govuk_publishing_components/presenters/attachment.rb, line 125 def abbr content_type_data[:abbr] end
content_type()
click to toggle source
# File lib/govuk_publishing_components/presenters/attachment.rb, line 121 def content_type content_type_data[:content_type] end
document?()
click to toggle source
# File lib/govuk_publishing_components/presenters/attachment.rb, line 137 def document? content_type_data[:document].present? end
name()
click to toggle source
# File lib/govuk_publishing_components/presenters/attachment.rb, line 129 def name content_type_data[:name] end
opendocument?()
click to toggle source
# File lib/govuk_publishing_components/presenters/attachment.rb, line 133 def opendocument? content_type_data[:opendocument].present? end
spreadsheet?()
click to toggle source
# File lib/govuk_publishing_components/presenters/attachment.rb, line 141 def spreadsheet? content_type_data[:spreadsheet].present? end