Class: LibBin::DataConverter::Str
- Defined in:
- lib/libbin/data_types.rb
Class Method Summary collapse
- .convert(input, output, input_big = LibBin::default_big?, output_big = !LibBin::default_big,, _ = nil, _ = nil) ⇒ Object
- .load(input, input_big = LibBin::default_big?, _ = nil, _ = nil) ⇒ Object
- .shape(value, previous_offset = 0, _ = nil, _ = nil, kind = DataShape) ⇒ Object
Methods inherited from Scalar
Class Method Details
.convert(input, output, input_big = LibBin::default_big?, output_big = !LibBin::default_big,, _ = nil, _ = nil) ⇒ Object
325 326 327 328 329 330 331 |
# File 'lib/libbin/data_types.rb', line 325 def self.convert(input, output, input_big = LibBin::default_big?, output_big = !LibBin::default_big, _ = nil, _ = nil) str = (@size < 0 ? input.readline("\x00") : input.read(@size)) value = (input_big ? @rl_be[str] : @rl_le[str]) str = (output_big ? @sl_be[value] : @sl_le[value]) output.write(str) value end |
.load(input, input_big = LibBin::default_big?, _ = nil, _ = nil) ⇒ Object
320 321 322 323 |
# File 'lib/libbin/data_types.rb', line 320 def self.load(input, input_big = LibBin::default_big?, _ = nil, _ = nil) str = (@size < 0 ? input.readline("\x00") : input.read(@size)) input_big ? @rl_be[str] : @rl_le[str] end |
.shape(value, previous_offset = 0, _ = nil, _ = nil, kind = DataShape) ⇒ Object
333 334 335 336 337 338 339 |
# File 'lib/libbin/data_types.rb', line 333 def self.shape(value, previous_offset = 0, _ = nil, _ = nil, kind = DataShape) if @size < 0 kind::new(previous_offset, previous_offset + value.size - 1) else kind::new(previous_offset, previous_offset + @size - 1) end end |