Class: ECFS::Document

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

Defined Under Namespace

Classes: Page

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Document

Returns a new instance of Document.



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/ecfs/document.rb', line 11

def initialize(params={})
  @filing = params["filing"]
  @url = params["url"]
  @pages = []
  io     = open(@url)
  reader = PDF::Reader.new(io)
  reader.pages.each_with_index do |page, index|
    @pages << ECFS::Document::Page.new({
      "text" => page.text,
      "page_number" => index + 1
    })
  end
end

Instance Attribute Details

#filingObject (readonly)

Returns the value of attribute filing.



8
9
10
# File 'lib/ecfs/document.rb', line 8

def filing
  @filing
end

#pagesObject (readonly)

Returns the value of attribute pages.



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

def pages
  @pages
end

#urlObject (readonly)

Returns the value of attribute url.



9
10
11
# File 'lib/ecfs/document.rb', line 9

def url
  @url
end

Instance Method Details

#full_textObject



25
26
27
# File 'lib/ecfs/document.rb', line 25

def full_text
  @pages.map {|p| p.text}.join(",")
end