Class: EideticPDF::PdfObjects::PdfString

Inherits:
Object
  • Object
show all
Defined in:
lib/epdfo.rb

Overview

text written between ()‘s with ’(‘, ’)‘, and ’' escaped with ‘'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ PdfString

Returns a new instance of PdfString.



160
161
162
# File 'lib/epdfo.rb', line 160

def initialize(value)
  @value = value.to_s
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



158
159
160
# File 'lib/epdfo.rb', line 158

def value
  @value
end

Class Method Details

.ary(string_ary) ⇒ Object



185
186
187
188
189
190
191
192
193
194
195
196
# File 'lib/epdfo.rb', line 185

def self.ary(string_ary)
  p_ary = string_ary.map do |s|
    if s.respond_to?(:to_str)
      PdfString.new(s.to_str)
    elsif s.respond_to?(:to_ary)
      PdfString.ary(s.to_ary)
    else
      s
    end
  end
  PdfArray.new p_ary
end

.escape(string) ⇒ Object



176
177
178
# File 'lib/epdfo.rb', line 176

def self.escape(string)
  string.gsub('\\','\\\\\\').gsub('(','\\(').gsub(')','\\)')
end

.escape_wide(string) ⇒ Object

TODO: What kind of changes are needed here?



181
182
183
# File 'lib/epdfo.rb', line 181

def self.escape_wide(string)
  string.gsub('\\','\\\\\\').gsub('(','\\(').gsub(')','\\)')
end

Instance Method Details

#==(other) ⇒ Object



168
169
170
# File 'lib/epdfo.rb', line 168

def ==(other)
  other.respond_to?(:value) && self.value == other.value
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


164
165
166
# File 'lib/epdfo.rb', line 164

def eql?(other)
  self.value.eql?(other.value)
end

#to_sObject



172
173
174
# File 'lib/epdfo.rb', line 172

def to_s
  "(#{PdfString.escape(value)}) "
end