Class: CompEx::UnsafeString

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ UnsafeString

Returns a new instance of UnsafeString.



7
8
9
10
11
12
13
14
15
# File 'lib/compex/unsafe_string.rb', line 7

def initialize(value)
  if value.is_a? UnsafeString
    @raw = value.raw
    @escaped = value.escaped
  else
    @raw = value
    @escaped = ERB::Util.html_escape(raw)
  end
end

Instance Attribute Details

#escapedObject (readonly)

Returns the value of attribute escaped.



5
6
7
# File 'lib/compex/unsafe_string.rb', line 5

def escaped
  @escaped
end

#rawObject (readonly)

Returns the value of attribute raw.



5
6
7
# File 'lib/compex/unsafe_string.rb', line 5

def raw
  @raw
end

Instance Method Details

#to_sObject



17
# File 'lib/compex/unsafe_string.rb', line 17

def to_s = @escaped