Class: Intelligence::MessageContent::Binary
- Defined in:
- lib/intelligence/message_content/binary.rb
Instance Attribute Summary collapse
-
#bytes ⇒ Object
readonly
Returns the value of attribute bytes.
-
#content_type ⇒ Object
readonly
Returns the value of attribute content_type.
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from Intelligence::MessageContent::Base
Instance Attribute Details
#bytes ⇒ Object (readonly)
Returns the value of attribute bytes.
12 13 14 |
# File 'lib/intelligence/message_content/binary.rb', line 12 def bytes @bytes end |
#content_type ⇒ Object (readonly)
Returns the value of attribute content_type.
11 12 13 |
# File 'lib/intelligence/message_content/binary.rb', line 11 def content_type @content_type end |
Instance Method Details
#image? ⇒ Boolean
19 20 21 22 |
# File 'lib/intelligence/message_content/binary.rb', line 19 def image? ( @content_type || false ) && ( MIME::Types[ @content_type ]&.first&.media_type == 'image' ) end |
#to_h ⇒ Object
24 25 26 |
# File 'lib/intelligence/message_content/binary.rb', line 24 def to_h { type: :binary, content_type: content_type, bytes: bytes } end |
#valid? ⇒ Boolean
14 15 16 17 |
# File 'lib/intelligence/message_content/binary.rb', line 14 def valid? ( @content_type || false ) && !MIME::Types[ @content_type ].empty? && ( @bytes || false ) && bytes.respond_to?( :empty? ) && !bytes.empty? end |