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.
255 256 257 |
# File 'lib/innodb/data_type.rb', line 255 def name @name end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
255 256 257 |
# File 'lib/innodb/data_type.rb', line 255 def width @width end |
Instance Method Details
#value(data) ⇒ Object
262 263 264 265 266 267 |
# File 'lib/innodb/data_type.rb', line 262 def value(data) time = BinData::Int24be.read(data) ^ (-1 << 23) sign = "-" if time < 0 time = time.abs "%s%02d:%02d:%02d" % [sign, time / 10000, (time / 100) % 100, time % 100] end |