Class: OpenPGP::Packet::LiteralData

Inherits:
OpenPGP::Packet show all
Defined in:
lib/openpgp/packet.rb

Overview

OpenPGP Literal Data packet (tag 11).

Constant Summary collapse

EYES_ONLY =
'_CONSOLE'

Instance Attribute Summary collapse

Attributes inherited from OpenPGP::Packet

#size, #tag

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from OpenPGP::Packet

#body, for, parse, parse_new_format, parse_old_format, tag

Constructor Details

#initialize(options = {}, &block) ⇒ LiteralData

Returns a new instance of LiteralData.



359
360
361
362
363
364
365
366
367
# File 'lib/openpgp/packet.rb', line 359

def initialize(options = {}, &block)
  defaults = {
    :format    => :b,
    :filename  => "",
    :timestamp => 0,
    :data      => "",
  }
  super(defaults.merge(options), &block)
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



347
348
349
# File 'lib/openpgp/packet.rb', line 347

def data
  @data
end

#filenameObject

Returns the value of attribute filename.



347
348
349
# File 'lib/openpgp/packet.rb', line 347

def filename
  @filename
end

#formatObject

Returns the value of attribute format.



347
348
349
# File 'lib/openpgp/packet.rb', line 347

def format
  @format
end

#timestampObject

Returns the value of attribute timestamp.



347
348
349
# File 'lib/openpgp/packet.rb', line 347

def timestamp
  @timestamp
end

Class Method Details

.parse_body(body, options = {}) ⇒ Object



349
350
351
352
353
354
355
356
357
# File 'lib/openpgp/packet.rb', line 349

def self.parse_body(body, options = {})
  defaults = {
    :format    => body.read_byte.chr.to_sym,
    :filename  => body.read_string,
    :timestamp => body.read_timestamp,
    :data      => body.read,
  }
  self.new(defaults.merge(options))
end

Instance Method Details

#eyes_only!Object



378
# File 'lib/openpgp/packet.rb', line 378

def eyes_only!() filename = EYES_ONLY end

#eyes_only?Boolean

Returns:

  • (Boolean)


379
# File 'lib/openpgp/packet.rb', line 379

def eyes_only?() filename == EYES_ONLY end

#write_body(buffer) ⇒ Object



369
370
371
372
373
374
# File 'lib/openpgp/packet.rb', line 369

def write_body(buffer)
  buffer.write_byte(format)
  buffer.write_string(filename)
  buffer.write_timestamp(timestamp)
  buffer.write(data.to_s)
end