Class: LS4::FileUpdateLog::Header
- Inherits:
-
Object
- Object
- LS4::FileUpdateLog::Header
- Defined in:
- lib/ls4/service/ulog_file.rb
Instance Attribute Summary collapse
-
#atime ⇒ Object
readonly
Returns the value of attribute atime.
-
#pos ⇒ Object
readonly
Returns the value of attribute pos.
Class Method Summary collapse
Instance Method Summary collapse
- #dump ⇒ Object
-
#initialize(atime, pos) ⇒ Header
constructor
A new instance of Header.
Constructor Details
#initialize(atime, pos) ⇒ Header
Returns a new instance of Header.
136 137 138 139 |
# File 'lib/ls4/service/ulog_file.rb', line 136 def initialize(atime, pos) @atime = atime @pos = pos end |
Instance Attribute Details
#atime ⇒ Object (readonly)
Returns the value of attribute atime.
141 142 143 |
# File 'lib/ls4/service/ulog_file.rb', line 141 def atime @atime end |
#pos ⇒ Object (readonly)
Returns the value of attribute pos.
142 143 144 |
# File 'lib/ls4/service/ulog_file.rb', line 142 def pos @pos end |
Class Method Details
.load(raw) ⇒ Object
153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/ls4/service/ulog_file.rb', line 153 def self.load(raw) magick = raw[0,8] if magick != MAGICK raise "magick not match" end atime = raw[8,8].unpack('NN') atime = (atime[0]<<32) | atime[1] pos = raw[16,8].unpack('NN') pos = (pos[0]<<32) | pos[1] new(atime, pos) end |
.read_offset(stream) ⇒ Object
167 168 169 170 171 172 173 |
# File 'lib/ls4/service/ulog_file.rb', line 167 def self.read_offset(stream) stream.pos = 16 raw = stream.read(8) pos = raw.unpack('NN') pos = (pos[0]<<32) | pos[1] pos end |
.write_offset(stream, pos) ⇒ Object
175 176 177 178 179 180 |
# File 'lib/ls4/service/ulog_file.rb', line 175 def self.write_offset(stream, pos) stream.pos = 16 raw = [pos>>32, pos&0xffffffff].pack('NN') stream.write(raw) stream end |
Instance Method Details
#dump ⇒ Object
144 145 146 147 148 149 150 151 |
# File 'lib/ls4/service/ulog_file.rb', line 144 def dump raw = "" raw << MAGICK raw << [ atime>>32, atime&0xffffffff].pack('NN') raw << [pos>>32, pos&0xffffffff].pack('NN') raw << ([0] * (HEADER_SIZE - raw.size)).pack('C*') raw end |