Class: OpenPGP::Packet::LiteralData

Inherits:
  • Object
show all
Defined in:
lib/openpgp/packet.rb

Overview

OpenPGP Literal Data packet (tag 11).

See Also:

Constant Summary

EYES_ONLY =
'_CONSOLE'

Instance Attribute Summary (collapse)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from

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

Constructor Details

- (LiteralData) initialize(options = {}, &block)

A new instance of LiteralData



379
380
381
382
383
384
385
386
387
# File 'lib/openpgp/packet.rb', line 379

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

Instance Attribute Details

- (Object) data

Returns the value of attribute data



367
368
369
# File 'lib/openpgp/packet.rb', line 367

def data
  @data
end

- (Object) filename

Returns the value of attribute filename



367
368
369
# File 'lib/openpgp/packet.rb', line 367

def filename
  @filename
end

- (Object) format

Returns the value of attribute format



367
368
369
# File 'lib/openpgp/packet.rb', line 367

def format
  @format
end

- (Object) timestamp

Returns the value of attribute timestamp



367
368
369
# File 'lib/openpgp/packet.rb', line 367

def timestamp
  @timestamp
end

Class Method Details

+ (Object) parse_body(body, options = {})



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

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

- (Object) eyes_only!



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

def eyes_only!() filename = EYES_ONLY end

- (Boolean) eyes_only?

Returns:

  • (Boolean)


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

def eyes_only?() filename == EYES_ONLY end

- (Object) write_body(buffer)



389
390
391
392
393
394
# File 'lib/openpgp/packet.rb', line 389

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