Class: Hpricot::BaseEle

Inherits:
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.



23
24
25
# File 'lib/hpricot/tag.rb', line 23

def parent
  @parent
end

#raw_stringObject

Returns the value of attribute raw_string.



23
24
25
# File 'lib/hpricot/tag.rb', line 23

def raw_string
  @raw_string
end

Class Method Details

.alterable(*fields) ⇒ Object



38
39
40
41
42
43
44
45
46
# File 'lib/hpricot/tag.rb', line 38

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



35
36
37
# File 'lib/hpricot/tag.rb', line 35

def altered!
  @raw_string = nil
end

#html_quote(str) ⇒ Object



24
25
26
# File 'lib/hpricot/tag.rb', line 24

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

#if_output(opts) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/hpricot/tag.rb', line 27

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

#pathnameObject



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

def pathname; self.name end