Class: Nokogiri::HTML::EntityLookup

Inherits:
Object
  • Object
show all
Defined in:
lib/nokogiri/html/entity_lookup.rb,
lib/nokogiri/ffi/html/entity_lookup.rb,
ext/nokogiri/html_entity_lookup.c

Instance Method Summary collapse

Instance Method Details

#[](name) ⇒ Object

Look up entity with name



8
9
10
# File 'lib/nokogiri/html/entity_lookup.rb', line 8

def [] name
  (val = get(name)) && val.value
end

#get(key) ⇒ Object

Get the HTML::EntityDescription for key



5
6
7
8
9
10
11
# File 'lib/nokogiri/ffi/html/entity_lookup.rb', line 5

def get(key) # :nodoc:
  ptr = LibXML.htmlEntityLookup(key.to_s)
  return nil if ptr.null?

  cstruct = LibXML::HtmlEntityDesc.new(ptr)
  EntityDescription.new cstruct[:value], cstruct[:name], cstruct[:desc]
end