Class: Buzzsaw::Document

Inherits:
Object
  • Object
show all
Includes:
DSL
Defined in:
lib/buzzsaw/document.rb

Constant Summary

Constants included from DSL

Buzzsaw::DSL::ENCODING_EXCEPTION

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from DSL

#asciify_target_text, #capture_target_text, #collect_by_xpath, #collect_target_text, #filter_target_text, #find_by_meta_tag, #find_by_schema_tag, #find_by_xpath, #find_in_table, #find_target_text, #get_content_for_meta_nodes, #get_nodes, #get_nodes_for_meta_attribute, #join_target_text, #label_by_meta_keywords, #label_by_url, #match_table_element, #match_target_text!, #meta_description, #meta_image, #meta_keywords, #meta_name, #meta_og, #meta_og_description, #meta_og_image, #meta_og_keywords, #meta_og_title, #meta_price, #meta_property, #meta_title, #sanitize, #schema_description, #schema_name, #schema_price

Constructor Details

#initialize(source, format: nil) ⇒ Document

Returns a new instance of Document.



6
7
8
9
10
11
12
13
14
# File 'lib/buzzsaw/document.rb', line 6

def initialize(source, format: nil)
  @doc = if format == :html
    Nokogiri::HTML(source)
  elsif format == :xml
    Nokogiri::XML(source)
  else
    Nokogiri.parse(source)
  end
end

Instance Attribute Details

#docObject (readonly)

Returns the value of attribute doc.



4
5
6
# File 'lib/buzzsaw/document.rb', line 4

def doc
  @doc
end