Class: Scrapetor::Dom::Comment

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, #doctype?, #document, #element?, #next_element_sibling, #next_sibling, #previous_element_sibling, #previous_sibling, #remove, #replace, #text?

Constructor Details

#initialize(data, parent: nil) ⇒ Comment

Returns a new instance of Comment.



376
377
378
379
# File 'lib/scrapetor/dom.rb', line 376

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

Instance Attribute Details

#dataObject

Returns the value of attribute data.



375
376
377
# File 'lib/scrapetor/dom.rb', line 375

def data
  @data
end

Instance Method Details

#comment?Boolean

Returns:

  • (Boolean)


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

def comment?; true; end

#contentObject



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

def content;  @data; end

#nameObject



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

def name;     "#comment"; end

#node_typeObject



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

def node_type; 8; end

#textObject



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

def text;     ""; end

#to_htmlObject



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

def to_html;  "<!--#{@data}-->"; end

#to_sObject



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

def to_s;     to_html; end