Sha256: ee59cf020b07ad6efd2dc3f0f15f2e190edb5b3b2fa8543adcdd838be8f4a62b

Contents?: true

Size: 557 Bytes

Versions: 3

Compression:

Stored size: 557 Bytes

Contents

class BuilderMutableString  
  def initialize(str)
    @state = str
  end
  
  def <<(text)
    @state += text
    self
  end
  
  def to_s
    @state
  end
  
  def to_str
    @state
  end
  
  def nil?
    @state.nil?
  end
  
  # Unpack doesn't exist in Opal
  def to_xs
    gsub(/&(?!\w+;)/, '&amp;')
    .gsub(/</, '&lt;')
    .gsub(/>/, '&gt;')
    .gsub(/'/, '&apos;')
  end
  
  def gsub(regex, replace)
    @state = @state.gsub regex,replace
    self
  end

  def ==(other_str)
    @state == other_str
  end
  
  def size
    @state.size
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
opal-builder-3.2.2.3 opal/opal/builder/builder_mutable_string.rb
opal-builder-3.2.2.2 opal/opal/builder/builder_mutable_string.rb
opal-builder-3.2.2.1 opal/opal/builder/builder_mutable_string.rb