Class: Firecrawl::Models::Document

Inherits:
Object
  • Object
show all
Defined in:
lib/firecrawl/models/document.rb

Overview

A scraped document returned by scrape, crawl, and batch endpoints.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Document

Returns a new instance of Document.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/firecrawl/models/document.rb', line 11

def initialize(data)
  @markdown = data["markdown"]
  @html = data["html"]
  @raw_html = data["rawHtml"]
  @json = data["json"]
  @summary = data["summary"]
  @metadata = data["metadata"]
  @links = data["links"]
  @images = data["images"]
  @screenshot = data["screenshot"]
  @audio = data["audio"]
  @attributes = data["attributes"]
  @actions = data["actions"]
  @warning = data["warning"]
  @change_tracking = data["changeTracking"]
  @branding = data["branding"]
end

Instance Attribute Details

#actionsObject (readonly)

Returns the value of attribute actions.



7
8
9
# File 'lib/firecrawl/models/document.rb', line 7

def actions
  @actions
end

#attributesObject (readonly)

Returns the value of attribute attributes.



7
8
9
# File 'lib/firecrawl/models/document.rb', line 7

def attributes
  @attributes
end

#audioObject (readonly)

Returns the value of attribute audio.



7
8
9
# File 'lib/firecrawl/models/document.rb', line 7

def audio
  @audio
end

#brandingObject (readonly)

Returns the value of attribute branding.



7
8
9
# File 'lib/firecrawl/models/document.rb', line 7

def branding
  @branding
end

#change_trackingObject (readonly)

Returns the value of attribute change_tracking.



7
8
9
# File 'lib/firecrawl/models/document.rb', line 7

def change_tracking
  @change_tracking
end

#htmlObject (readonly)

Returns the value of attribute html.



7
8
9
# File 'lib/firecrawl/models/document.rb', line 7

def html
  @html
end

#imagesObject (readonly)

Returns the value of attribute images.



7
8
9
# File 'lib/firecrawl/models/document.rb', line 7

def images
  @images
end

#jsonObject (readonly)

Returns the value of attribute json.



7
8
9
# File 'lib/firecrawl/models/document.rb', line 7

def json
  @json
end

Returns the value of attribute links.



7
8
9
# File 'lib/firecrawl/models/document.rb', line 7

def links
  @links
end

#markdownObject (readonly)

Returns the value of attribute markdown.



7
8
9
# File 'lib/firecrawl/models/document.rb', line 7

def markdown
  @markdown
end

#metadataObject (readonly)

Returns the value of attribute metadata.



7
8
9
# File 'lib/firecrawl/models/document.rb', line 7

def 
  @metadata
end

#raw_htmlObject (readonly)

Returns the value of attribute raw_html.



7
8
9
# File 'lib/firecrawl/models/document.rb', line 7

def raw_html
  @raw_html
end

#screenshotObject (readonly)

Returns the value of attribute screenshot.



7
8
9
# File 'lib/firecrawl/models/document.rb', line 7

def screenshot
  @screenshot
end

#summaryObject (readonly)

Returns the value of attribute summary.



7
8
9
# File 'lib/firecrawl/models/document.rb', line 7

def summary
  @summary
end

#warningObject (readonly)

Returns the value of attribute warning.



7
8
9
# File 'lib/firecrawl/models/document.rb', line 7

def warning
  @warning
end

Instance Method Details

#to_sObject



29
30
31
32
33
# File 'lib/firecrawl/models/document.rb', line 29

def to_s
  title = &.dig("title") || "untitled"
  url = &.dig("sourceURL") || "unknown"
  "Document{title=#{title}, url=#{url}}"
end