Class: Tapyrus::PSTT::Proprietary
- Inherits:
-
Object
- Object
- Tapyrus::PSTT::Proprietary
- Defined in:
- lib/tapyrus/pstt/proprietary.rb
Overview
A proprietary record, for applications that need non-standardized fields.
Instance Attribute Summary collapse
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
-
#subkeydata ⇒ Object
readonly
Returns the value of attribute subkeydata.
-
#subtype ⇒ Object
readonly
Returns the value of attribute subtype.
-
#value ⇒ String
The value data with binary format.
Class Method Summary collapse
-
.parse_from_record(record) ⇒ Tapyrus::PSTT::Proprietary
Parse a proprietary record.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(identifier:, subtype:, subkeydata: "".b, value: "".b) ⇒ Proprietary
constructor
A new instance of Proprietary.
-
#to_keydata ⇒ String
The key data of this record with binary format.
- #to_record(type) ⇒ Tapyrus::PSTT::KeyValue
Constructor Details
#initialize(identifier:, subtype:, subkeydata: "".b, value: "".b) ⇒ Proprietary
Returns a new instance of Proprietary.
21 22 23 24 25 26 |
# File 'lib/tapyrus/pstt/proprietary.rb', line 21 def initialize(identifier:, subtype:, subkeydata: "".b, value: "".b) @identifier = identifier @subtype = subtype @subkeydata = subkeydata @value = value end |
Instance Attribute Details
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
7 8 9 |
# File 'lib/tapyrus/pstt/proprietary.rb', line 7 def identifier @identifier end |
#subkeydata ⇒ Object (readonly)
Returns the value of attribute subkeydata.
15 16 17 |
# File 'lib/tapyrus/pstt/proprietary.rb', line 15 def subkeydata @subkeydata end |
#subtype ⇒ Object (readonly)
Returns the value of attribute subtype.
11 12 13 |
# File 'lib/tapyrus/pstt/proprietary.rb', line 11 def subtype @subtype end |
#value ⇒ String
Returns the value data with binary format.
19 20 21 |
# File 'lib/tapyrus/pstt/proprietary.rb', line 19 def value @value end |
Class Method Details
.parse_from_record(record) ⇒ Tapyrus::PSTT::Proprietary
Parse a proprietary record.
31 32 33 34 35 36 |
# File 'lib/tapyrus/pstt/proprietary.rb', line 31 def self.parse_from_record(record) buf = StringIO.new(record.keydata) identifier = PSTT.read_bytes(buf, PSTT.read_compact_size(buf)) subtype = PSTT.read_compact_size(buf) new(identifier: identifier, subtype: subtype, subkeydata: buf.read || "".b, value: record.value) end |
Instance Method Details
#==(other) ⇒ Object
49 50 51 |
# File 'lib/tapyrus/pstt/proprietary.rb', line 49 def ==(other) other.is_a?(Proprietary) && to_keydata == other.to_keydata && value == other.value end |
#to_keydata ⇒ String
Returns the key data of this record with binary format.
39 40 41 |
# File 'lib/tapyrus/pstt/proprietary.rb', line 39 def to_keydata Tapyrus.pack_var_string(identifier) + Tapyrus.pack_var_int(subtype) + subkeydata end |
#to_record(type) ⇒ Tapyrus::PSTT::KeyValue
45 46 47 |
# File 'lib/tapyrus/pstt/proprietary.rb', line 45 def to_record(type) KeyValue.new(type, to_keydata, value) end |