Class: Mapricot::AbstractNode

Inherits:
Object
  • Object
show all
Defined in:
lib/mapricot/abstract_doc.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(unode) ⇒ AbstractNode

Returns a new instance of AbstractNode.



71
72
73
# File 'lib/mapricot/abstract_doc.rb', line 71

def initialize(unode) 
  @unode = unode        # unresolved node
end

Instance Attribute Details

#unodeObject (readonly)

Returns the value of attribute unode.



69
70
71
# File 'lib/mapricot/abstract_doc.rb', line 69

def unode
  @unode
end

Instance Method Details

#attributesObject



79
80
81
82
83
84
85
86
87
# File 'lib/mapricot/abstract_doc.rb', line 79

def attributes
  if Mapricot.parser != :nokogiri
    @unode.attributes
  else
    atts = {}
    @unode.attributes.each {|k,v| atts[k] = v.value}
    atts
  end
end

#contentsObject



89
90
91
92
93
94
95
# File 'lib/mapricot/abstract_doc.rb', line 89

def contents
  if Mapricot.parser == :libxml || Mapricot.parser == :nokogiri
    @unode.content
  else
    @unode.inner_html
  end
end

#to_sObject



75
76
77
# File 'lib/mapricot/abstract_doc.rb', line 75

def to_s
  @unode.to_s
end