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



138
139
140
141
# File 'lib/reparcs/base.rb', line 138

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.



154
155
156
# File 'lib/reparcs/base.rb', line 154

def string_name
  @string_name
end

Instance Method Details

#append(text) ⇒ Object

Append a string to the string



147
148
149
150
151
152
153
# File 'lib/reparcs/base.rb', line 147

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



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

def to_html
  return @stri
end