Class: Base::StringElement

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

Overview

A String, you do not need to directly create a StringElement object If you append a string to any container type element, one will be created for you.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stri) ⇒ StringElement

Create a new StringElement



142
143
144
145
# File 'lib/reparcs/base.rb', line 142

def initialize(stri)
  @stri = put_xml_entities(stri)
  @string_name = "string"
end

Instance Attribute Details

#string_nameObject (readonly)

Returns the value of attribute string_name.



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

def string_name
  @string_name
end

Instance Method Details

#append(text) ⇒ Object

Append a string to the string



151
152
153
154
155
156
157
# File 'lib/reparcs/base.rb', line 151

def append(text)
  if text.class == String
    @stri << put_xml_entities(text)
  else
    raise "#{self.to_html} is a String, you can only append String's to it!"
  end
end

#to_htmlObject

Returns the string representation of this element



147
148
149
# File 'lib/reparcs/base.rb', line 147

def to_html
  return @stri
end