Class: Exerb::String
- Inherits:
-
Object
- Object
- Exerb::String
- Defined in:
- lib/exerb/string.rb
Overview
#
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(name, value) ⇒ String
constructor
A new instance of String.
- #pack ⇒ Object
Constructor Details
#initialize(name, value) ⇒ String
Returns a new instance of String.
15 16 17 18 |
# File 'lib/exerb/string.rb', line 15 def initialize (name, value) @name = name @value = value end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
20 21 22 |
# File 'lib/exerb/string.rb', line 20 def name @name end |
#value ⇒ Object
Returns the value of attribute value.
20 21 22 |
# File 'lib/exerb/string.rb', line 20 def value @value end |
Instance Method Details
#pack ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/exerb/string.rb', line 22 def pack # next two lines work for Ascii # fmtstr = "SA#{@value.length}SSSSSSSSSSSSSSS" # return [@value.length,@value,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].pack(fmtstr) # We want UTF-16 - who knew? intchrs = [] intchrs[0] = @value.length @value.each_byte {|c| intchrs << c.to_i} 15.times {|i| intchrs << 0} return intchrs.pack("S#{intchrs.length}") end |