Class: HTMLToken

Inherits:
Object
  • Object
show all
Defined in:
lib/openid/yadis/htmltokenizer.rb

Overview

The parent class for all three types of HTML tokens

Direct Known Subclasses

HTMLComment, HTMLTag, HTMLText

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ HTMLToken

Initialize the token based on the raw text



170
171
172
# File 'lib/openid/yadis/htmltokenizer.rb', line 170

def initialize(text)
  @raw = text
end

Instance Attribute Details

#rawObject

Returns the value of attribute raw.



167
168
169
# File 'lib/openid/yadis/htmltokenizer.rb', line 167

def raw
  @raw
end

Instance Method Details

#==(other) ⇒ Object

Compare to another based on the raw source



189
190
191
# File 'lib/openid/yadis/htmltokenizer.rb', line 189

def ==(other)
  raw == other.to_s
end

#textObject

By default tokens have no text representation



180
181
182
# File 'lib/openid/yadis/htmltokenizer.rb', line 180

def text
  ""
end

#to_sObject

By default, return exactly the string used to create the text



175
176
177
# File 'lib/openid/yadis/htmltokenizer.rb', line 175

def to_s
  raw
end

#trimmed_textObject



184
185
186
# File 'lib/openid/yadis/htmltokenizer.rb', line 184

def trimmed_text
  text.strip.gsub(/\s+/m, " ")
end