class PSD::EngineData::Instruction::String

Public Class Methods

token() click to toggle source
# File lib/psd/enginedata/instructions/string.rb, line 5
def self.token; Regexp.new('^\(\xFE\xFF(.*)\)$'.force_encoding('binary')); end

Public Instance Methods

execute!() click to toggle source
# File lib/psd/enginedata/instructions/string.rb, line 7
def execute!
  data = self.class.token.match(
    @text.force_encoding('binary')
  )[1]

  begin
    data
      .force_encoding('UTF-16BE')
      .encode('UTF-8', 'UTF-16BE', universal_newline: true)
      .strip
  rescue
    data
  end
end