Class: ITerm2::Protocol::FileSequence
- Inherits:
-
Object
- Object
- ITerm2::Protocol::FileSequence
- Includes:
- Aspect::HasAttributes
- Defined in:
- lib/iterm2/protocol/file_sequence.rb
Overview
Escape sequence for use file downloads.
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ FileSequence
constructor
A new instance of FileSequence.
-
#inline ⇒ Boolean
Get whether the file will be displayed inline.
-
#inline= ⇒ Boolean
Set whether the file will be displayed inline.
-
#path ⇒ String
Get the path.
-
#path= ⇒ String
Set the path.
-
#to_h(output = nil) ⇒ Hash
Return the arguments to this escape sequence.
-
#to_s(attributes = {}) ⇒ String
Get the escape sequence.
Constructor Details
#initialize(attributes = {}) ⇒ FileSequence
Returns a new instance of FileSequence.
21 22 23 24 25 26 27 |
# File 'lib/iterm2/protocol/file_sequence.rb', line 21 def initialize(attributes={}) @inline = false update_attributes(attributes) raise ArgumentError, "path must be given" if @path.nil? end |
Class Method Details
.format(attributes = {}) ⇒ Object
13 14 15 |
# File 'lib/iterm2/protocol/file_sequence.rb', line 13 def format(attributes={}) new(attributes).to_s end |
Instance Method Details
#inline ⇒ Boolean
Get whether the file will be displayed inline.
|
|
# File 'lib/iterm2/protocol/file_sequence.rb', line 41
|
#inline= ⇒ Boolean
Set whether the file will be displayed inline.
51 |
# File 'lib/iterm2/protocol/file_sequence.rb', line 51 attribute(:inline, query: true) |
#path ⇒ String
Get the path.
|
|
# File 'lib/iterm2/protocol/file_sequence.rb', line 29
|
#path= ⇒ String
Set the path.
39 |
# File 'lib/iterm2/protocol/file_sequence.rb', line 39 attribute(:path) { |value| value.is_a?(Pathname) ? value : Pathname.new(value.to_s) } |
#to_h(output = nil) ⇒ Hash
Return the arguments to this escape sequence.
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/iterm2/protocol/file_sequence.rb', line 60 def to_h(output=nil) result = { name: Base64.encode64(@path.to_s), size: @path.size } result[:inline] = output == :terminal ? (@inline ? 1 : 0) : @inline result end |
#to_s(attributes = {}) ⇒ String
Get the escape sequence.
75 76 77 78 79 80 81 82 83 |
# File 'lib/iterm2/protocol/file_sequence.rb', line 75 def to_s(attributes={}) attributes = { key: "File", value: to_h(:terminal), content: Base64.encode64(@path.read) }.merge(attributes) Formatter.format(attributes) end |