Class: Scrapetor::Dom::AttrNode

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, value, owner) ⇒ AttrNode

Returns a new instance of AttrNode.



406
407
408
409
410
# File 'lib/scrapetor/dom.rb', line 406

def initialize(name, value, owner)
  @name = name
  @value = value
  @owner = owner
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



405
406
407
# File 'lib/scrapetor/dom.rb', line 405

def name
  @name
end

#ownerObject (readonly)

Returns the value of attribute owner.



405
406
407
# File 'lib/scrapetor/dom.rb', line 405

def owner
  @owner
end

#valueObject (readonly)

Returns the value of attribute value.



405
406
407
# File 'lib/scrapetor/dom.rb', line 405

def value
  @value
end

Instance Method Details

#textObject Also known as: content, inner_text

Nokogiri-compat: attribute nodes expose .text / .content / .inner_text that return the attribute’s value. Real-world code iterates ‘node.attribute_nodes` and reads `.text` on each.



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

def text;       @value.to_s; end

#to_sObject



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

def to_s;       "#{@name}=\"#{@value}\""; end