Class: RubyRich::Attachment

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_rich/attachment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, path:, mime_type: nil, display_name: nil, metadata: {}) ⇒ Attachment

Returns a new instance of Attachment.



7
8
9
10
11
12
13
# File 'lib/ruby_rich/attachment.rb', line 7

def initialize(type:, path:, mime_type: nil, display_name: nil, metadata: {})
  @type = type.to_sym
  @path = path.to_s
  @mime_type = mime_type
  @display_name = display_name || File.basename(@path)
  @metadata = .dup
end

Instance Attribute Details

#display_nameObject

Returns the value of attribute display_name.



5
6
7
# File 'lib/ruby_rich/attachment.rb', line 5

def display_name
  @display_name
end

#metadataObject

Returns the value of attribute metadata.



5
6
7
# File 'lib/ruby_rich/attachment.rb', line 5

def 
  @metadata
end

#mime_typeObject

Returns the value of attribute mime_type.



5
6
7
# File 'lib/ruby_rich/attachment.rb', line 5

def mime_type
  @mime_type
end

#pathObject

Returns the value of attribute path.



5
6
7
# File 'lib/ruby_rich/attachment.rb', line 5

def path
  @path
end

#typeObject

Returns the value of attribute type.



5
6
7
# File 'lib/ruby_rich/attachment.rb', line 5

def type
  @type
end

Instance Method Details

#to_hObject



15
16
17
18
19
20
21
22
23
# File 'lib/ruby_rich/attachment.rb', line 15

def to_h
  {
    type: @type,
    path: @path,
    mime_type: @mime_type,
    display_name: @display_name,
    metadata: @metadata
  }.compact
end