Class: Nis::Struct::Message
- Inherits:
-
Object
- Object
- Nis::Struct::Message
- Defined in:
- lib/nis/struct/message.rb
Constant Summary collapse
- TYPE_PLAIN =
1- TYPE_ENCRYPTED =
2
Instance Attribute Summary collapse
-
#payload ⇒ String
The current value of payload.
-
#type ⇒ Integer
The current value of type.
-
#value ⇒ String
The current value of value.
Instance Method Summary collapse
- #==(other) ⇒ Boolean
- #bytesize ⇒ Integer
- #encrypted? ⇒ Boolean
-
#initialize(value = '') ⇒ Message
constructor
A new instance of Message.
- #plain? ⇒ Boolean
- #to_hash ⇒ Hash
- #to_s ⇒ String
- #valid? ⇒ Boolean
Constructor Details
#initialize(value = '') ⇒ Message
Returns a new instance of Message.
11 12 13 14 |
# File 'lib/nis/struct/message.rb', line 11 def initialize(value = '') @value = value @type = TYPE_PLAIN end |
Instance Attribute Details
#payload ⇒ String
Returns the current value of payload.
5 6 7 |
# File 'lib/nis/struct/message.rb', line 5 def payload @payload end |
#type ⇒ Integer
Returns the current value of type.
5 6 7 |
# File 'lib/nis/struct/message.rb', line 5 def type @type end |
#value ⇒ String
Returns the current value of value.
5 6 7 |
# File 'lib/nis/struct/message.rb', line 5 def value @value end |
Instance Method Details
#==(other) ⇒ Boolean
47 48 49 |
# File 'lib/nis/struct/message.rb', line 47 def ==(other) @value == other.value end |
#bytesize ⇒ Integer
27 28 29 |
# File 'lib/nis/struct/message.rb', line 27 def bytesize payload.bytesize end |
#encrypted? ⇒ Boolean
17 18 19 |
# File 'lib/nis/struct/message.rb', line 17 def encrypted? @type == TYPE_ENCRYPTED end |
#plain? ⇒ Boolean
22 23 24 |
# File 'lib/nis/struct/message.rb', line 22 def plain? @type == TYPE_PLAIN end |
#to_hash ⇒ Hash
37 38 39 |
# File 'lib/nis/struct/message.rb', line 37 def to_hash { payload: payload, type: @type } end |
#to_s ⇒ String
42 43 44 |
# File 'lib/nis/struct/message.rb', line 42 def to_s @value end |
#valid? ⇒ Boolean
32 33 34 |
# File 'lib/nis/struct/message.rb', line 32 def valid? bytesize <= 512 end |