Class: Relay::Attachment
- Inherits:
-
Object
- Object
- Relay::Attachment
- Defined in:
- lib/relay/attachment.rb,
lib/relay/attachment/session.rb
Defined Under Namespace
Classes: Session
Instance Attribute Summary collapse
- #name ⇒ String readonly
- #path ⇒ String readonly
- #type ⇒ String readonly
Class Method Summary collapse
Instance Method Summary collapse
- #attached? ⇒ Boolean
- #file? ⇒ Boolean
-
#initialize(name: nil, path: nil, type: nil) ⇒ Attachment
constructor
A new instance of Attachment.
- #to_h ⇒ Hash<String, String>
Constructor Details
#initialize(name: nil, path: nil, type: nil) ⇒ Attachment
Returns a new instance of Attachment.
20 21 22 23 24 |
# File 'lib/relay/attachment.rb', line 20 def initialize(name: nil, path: nil, type: nil) @name = name.to_s @path = path.to_s @type = type.to_s end |
Instance Attribute Details
#name ⇒ String (readonly)
28 29 30 |
# File 'lib/relay/attachment.rb', line 28 def name @name end |
#path ⇒ String (readonly)
32 33 34 |
# File 'lib/relay/attachment.rb', line 32 def path @path end |
#type ⇒ String (readonly)
36 37 38 |
# File 'lib/relay/attachment.rb', line 36 def type @type end |
Class Method Details
.session(session:, root:, user: nil, provider: nil) ⇒ Relay::Attachment::Session
12 13 14 |
# File 'lib/relay/attachment.rb', line 12 def self.session(session:, root:, user: nil, provider: nil) Session.new(session:, root:, user:, provider:) end |
Instance Method Details
#attached? ⇒ Boolean
46 47 48 |
# File 'lib/relay/attachment.rb', line 46 def attached? file? end |
#file? ⇒ Boolean
40 41 42 |
# File 'lib/relay/attachment.rb', line 40 def file? !path.empty? && File.file?(path) end |
#to_h ⇒ Hash<String, String>
52 53 54 |
# File 'lib/relay/attachment.rb', line 52 def to_h {"name" => name, "path" => path, "type" => type} end |