Class: PDFKit::Source

Inherits:
Object
  • Object
show all
Defined in:
lib/pdfkit/source.rb

Instance Method Summary collapse

Constructor Details

#initialize(url_file_or_html) ⇒ Source

Returns a new instance of Source.



5
6
7
# File 'lib/pdfkit/source.rb', line 5

def initialize(url_file_or_html)
  @source = url_file_or_html
end

Instance Method Details

#file?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/pdfkit/source.rb', line 13

def file?
  @source.kind_of?(File)
end

#html?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/pdfkit/source.rb', line 17

def html?
  !(url? || file?)
end

#to_sObject



21
22
23
# File 'lib/pdfkit/source.rb', line 21

def to_s
  file? ? @source.path : @source
end

#url?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/pdfkit/source.rb', line 9

def url?
  @source.is_a?(String) && @source.match(/^http/)
end