Class: Serenity::TextLine
- Inherits:
-
Line
- Object
- Line
- Serenity::TextLine
show all
- Defined in:
- lib/serenity/line.rb
Instance Attribute Summary
Attributes inherited from Line
#text
Instance Method Summary
collapse
Methods inherited from Line
#clone, code, #initialize, literal, string, text, #to_s
Constructor Details
This class inherits a constructor from Serenity::Line
Instance Method Details
#escape_text(text) ⇒ Object
40
41
42
|
# File 'lib/serenity/line.rb', line 40
def escape_text text
text.gsub(/['\\]/, '\\\\\&')
end
|
#set_attribute(key, val) ⇒ Object
44
45
46
47
48
49
50
51
52
|
# File 'lib/serenity/line.rb', line 44
def set_attribute(key, val)
tag = Nokogiri.XML(@text).children[0]
tag[key] = val
updated_text = tag.to_s
updated_text.gsub!('/','') unless @text.include?('/')
@text = updated_text
end
|
#to_buf ⇒ Object
36
37
38
|
# File 'lib/serenity/line.rb', line 36
def to_buf
" _buf << '" << escape_text(@text) << "';"
end
|