Class: Elparser::SExpString
- Inherits:
-
AbstractSExpAtom
- Object
- AbstractSExp
- AbstractSExpAtom
- Elparser::SExpString
- Defined in:
- lib/elparser.rb
Instance Attribute Summary collapse
-
#str ⇒ Object
readonly
Returns the value of attribute str.
Instance Method Summary collapse
-
#initialize(str) ⇒ SExpString
constructor
A new instance of SExpString.
- #to_ruby ⇒ Object
- #to_s ⇒ Object
Methods inherited from AbstractSExpAtom
Methods inherited from AbstractSExp
#==, #atom?, #cons?, #list?, #visit
Constructor Details
#initialize(str) ⇒ SExpString
Returns a new instance of SExpString.
64 65 66 |
# File 'lib/elparser.rb', line 64 def initialize(str) @str = str end |
Instance Attribute Details
#str ⇒ Object (readonly)
Returns the value of attribute str.
63 64 65 |
# File 'lib/elparser.rb', line 63 def str @str end |
Instance Method Details
#to_ruby ⇒ Object
78 79 80 |
# File 'lib/elparser.rb', line 78 def to_ruby @str end |
#to_s ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/elparser.rb', line 67 def to_s # replace unicode point escape syntax : \u{xxxx} -> \uxxxx, \u{yyyyy} -> \U000yyyyy @str.dump.gsub(/\\u\{(\h{4,6})\}/) do |m| i = $1 if i.size == 4 then "\\u#{i}" else "\\U00%06x"%(i.hex) end end end |