Module: Packable::Extensions::String
- Defined in:
- lib/packable/extensions/string.rb
Overview
:nodoc:
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/packable/extensions/string.rb', line 7 def self.included(base) base.class_eval do include Packable extend ClassMethods alias_method :unpack_without_long_form, :unpack alias_method :unpack, :unpack_with_long_form packers.set :merge_all, :fill => " " end end |
Instance Method Details
#unpack_with_long_form(*arg) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/packable/extensions/string.rb', line 22 def unpack_with_long_form(*arg) return unpack_without_long_form(*arg) if arg.first.is_a? String StringIO.new(self).packed.read(*arg) rescue EOFError nil end |
#write_packed(io, options) ⇒ Object
17 18 19 20 |
# File 'lib/packable/extensions/string.rb', line 17 def write_packed(io, ) return io.write_without_packing(self) unless [:bytes] io.write_without_packing(self[0...[:bytes]].ljust([:bytes], [:fill] || "\000")) end |