Class: Hpricot::BaseEle

Inherits:
Object
  • Object
show all
Defined in:
lib/hpricot/tag.rb

Direct Known Subclasses

Comment, DocType, ETag, ProcIns, STag, Text, XMLDecl

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#parentObject

Returns the value of attribute parent.



19
20
21
# File 'lib/hpricot/tag.rb', line 19

def parent
  @parent
end

#raw_stringObject

Returns the value of attribute raw_string.



19
20
21
# File 'lib/hpricot/tag.rb', line 19

def raw_string
  @raw_string
end

Class Method Details

.alterable(*fields) ⇒ Object



34
35
36
37
38
39
40
41
42
# File 'lib/hpricot/tag.rb', line 34

def self.alterable(*fields)
  attr_accessor(*fields)
  fields.each do |f|
    define_method("#{f}=") do |v|
      altered!
      instance_variable_set("@#{f}", v)
    end
  end
end

Instance Method Details

#altered!Object



31
32
33
# File 'lib/hpricot/tag.rb', line 31

def altered!
  @raw_string = nil
end

#html_quote(str) ⇒ Object



20
21
22
# File 'lib/hpricot/tag.rb', line 20

def html_quote(str)
  "\"" + str.gsub('"', '\\"') + "\""
end

#if_output(opts) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/hpricot/tag.rb', line 23

def if_output(opts)
  if opts[:preserve] and not @raw_string.nil?
    @raw_string
  else
    yield opts
  end
end

#pathnameObject



30
# File 'lib/hpricot/tag.rb', line 30

def pathname; self.name end