Module: BSON::Time
- Defined in:
- lib/bson/time.rb
Overview
Injects behaviour for encoding and decoding time values to and from raw bytes as specified by the BSON spec.
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- BSON_TYPE =
A time is type 0x09 in the BSON spec.
9.chr.force_encoding(BINARY).freeze
Instance Method Summary collapse
-
#to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) ⇒ String
Get the time as encoded BSON.
Instance Method Details
#to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) ⇒ String
Get the time as encoded BSON.
40 41 42 |
# File 'lib/bson/time.rb', line 40 def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) buffer.put_int64((to_i * 1000) + (usec / 1000)) end |