Class: Gqldb::TypedValue
- Inherits:
-
Object
- Object
- Gqldb::TypedValue
- Defined in:
- lib/tina4_ultipa/pb.rb
Overview
---- messages -------------------------------------------------------------
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#is_null ⇒ Object
Returns the value of attribute is_null.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(type: 0, data: "".b, is_null: false) ⇒ TypedValue
constructor
A new instance of TypedValue.
Constructor Details
#initialize(type: 0, data: "".b, is_null: false) ⇒ TypedValue
Returns a new instance of TypedValue.
178 179 180 181 182 |
# File 'lib/tina4_ultipa/pb.rb', line 178 def initialize(type: 0, data: "".b, is_null: false) @type = PropertyType.id_of(type) @data = (data || "".b).dup.force_encoding("BINARY") @is_null = is_null end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
176 177 178 |
# File 'lib/tina4_ultipa/pb.rb', line 176 def data @data end |
#is_null ⇒ Object
Returns the value of attribute is_null.
176 177 178 |
# File 'lib/tina4_ultipa/pb.rb', line 176 def is_null @is_null end |
#type ⇒ Object
Returns the value of attribute type.
176 177 178 |
# File 'lib/tina4_ultipa/pb.rb', line 176 def type @type end |
Class Method Details
.decode(bytes) ⇒ Object
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
# File 'lib/tina4_ultipa/pb.rb', line 192 def self.decode(bytes) o = new r = Reader.new(bytes) until r.eof? tag = r.read_varint fn = tag >> 3 wt = tag & 7 if fn == 1 && wt == 0 then o.type = r.read_varint elsif fn == 2 && wt == 2 then o.data = r.read_len elsif fn == 3 && wt == 0 then o.is_null = !r.read_varint.zero? else r.skip(wt) end end o end |
.encode(msg) ⇒ Object
184 185 186 187 188 189 190 |
# File 'lib/tina4_ultipa/pb.rb', line 184 def self.encode(msg) buf = "".b Wire.write_varint(buf, 1, msg.type) Wire.write_bytes(buf, 2, msg.data) Wire.write_bool(buf, 3, msg.is_null) buf end |