class RichUrls::El
Constants
- MAX_TEXT_LENGTH
Attributes
attributes[R]
open[R]
tag[R]
Public Class Methods
new(tag)
click to toggle source
# File lib/el.rb, line 7 def initialize(tag) @tag = tag @open = true @attributes = {} end
Public Instance Methods
add(key, value)
click to toggle source
# File lib/el.rb, line 13 def add(key, value) return if @attributes[key] @attributes[key] = value end
append_text(str)
click to toggle source
# File lib/el.rb, line 19 def append_text(str) @attributes[:text] ||= '' str = str.strip length = @attributes[:text].length if length <= MAX_TEXT_LENGTH end_slice = MAX_TEXT_LENGTH - length sliced = str[0...end_slice] @attributes[:text] << sliced + ' ' end end
close!()
click to toggle source
# File lib/el.rb, line 37 def close! @open = false end
text()
click to toggle source
# File lib/el.rb, line 33 def text @attributes[:text]&.strip end