Class: WeasyPrint::Source

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

Instance Method Summary collapse

Constructor Details

#initialize(url_file_or_html) ⇒ Source

Returns a new instance of Source.



3
4
5
# File 'lib/weasyprint/source.rb', line 3

def initialize(url_file_or_html)
  @source = url_file_or_html
end

Instance Method Details

#file?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/weasyprint/source.rb', line 11

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

#html?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/weasyprint/source.rb', line 15

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

#to_sObject



19
20
21
# File 'lib/weasyprint/source.rb', line 19

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

#url?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/weasyprint/source.rb', line 7

def url?
  @source.is_a?(String) && @source.match(/\Ahttp/)
end