Class: Innodb::DataType::TimeType
- Inherits:
-
Object
- Object
- Innodb::DataType::TimeType
- Defined in:
- lib/innodb/data_type.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
-
#initialize(base_type, modifiers, properties) ⇒ TimeType
constructor
A new instance of TimeType.
- #value(data) ⇒ Object
Constructor Details
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
272 273 274 |
# File 'lib/innodb/data_type.rb', line 272 def name @name end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
273 274 275 |
# File 'lib/innodb/data_type.rb', line 273 def width @width end |
Instance Method Details
#value(data) ⇒ Object
280 281 282 283 284 285 |
# File 'lib/innodb/data_type.rb', line 280 def value(data) time = BinData::Int24be.read(data) ^ (-1 << 23) sign = "-" if time.negative? time = time.abs "%s%02d:%02d:%02d" % [sign, time / 10_000, (time / 100) % 100, time % 100] end |