Class: Scrapetor::Dom::Text

Inherits:
Object
  • Object
show all
Includes:
NodeMethods
Defined in:
lib/scrapetor/dom.rb

Instance Attribute Summary collapse

Attributes included from NodeMethods

#parent

Instance Method Summary collapse

Methods included from NodeMethods

#add_next_sibling, #add_previous_sibling, #comment?, #doctype?, #document, #element?, #next_element_sibling, #next_sibling, #previous_element_sibling, #previous_sibling, #remove, #replace

Constructor Details

#initialize(data, parent: nil) ⇒ Text

Returns a new instance of Text.



360
361
362
363
# File 'lib/scrapetor/dom.rb', line 360

def initialize(data, parent: nil)
  @data = data.to_s
  @parent = parent
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



359
360
361
# File 'lib/scrapetor/dom.rb', line 359

def data
  @data
end

Instance Method Details

#contentObject



365
# File 'lib/scrapetor/dom.rb', line 365

def content;  @data; end

#nameObject



367
# File 'lib/scrapetor/dom.rb', line 367

def name;     "#text"; end

#node_typeObject



370
# File 'lib/scrapetor/dom.rb', line 370

def node_type; 3; end

#textObject



364
# File 'lib/scrapetor/dom.rb', line 364

def text;     @data; end

#text?Boolean

Returns:

  • (Boolean)


366
# File 'lib/scrapetor/dom.rb', line 366

def text?;    true;  end

#to_htmlObject



368
# File 'lib/scrapetor/dom.rb', line 368

def to_html;  Dom.escape_text(@data); end

#to_sObject



369
# File 'lib/scrapetor/dom.rb', line 369

def to_s;     @data; end