Class: Preproc::IncludeReader

Inherits:
Object
  • Object
show all
Includes:
LogUtils::Logging
Defined in:
lib/preproc.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text, opts = {}) ⇒ IncludeReader

Returns a new instance of IncludeReader.



54
55
56
57
58
59
# File 'lib/preproc.rb', line 54

def initialize( text, opts={} )
  @text = text
  @base = opts[:base]

  logger.debug("  base: #{@base}")
end

Class Method Details

.from_url(src) ⇒ Object



45
46
47
48
49
50
51
# File 'lib/preproc.rb', line 45

def self.from_url( src )
  uri = URI.parse( src )
  text = Preproc.fetcher_read_utf8!( src )

  base_path = uri.path[0..uri.path.rindex('/')]  # get everything upto incl. last slash (/)
  self.new( text, base: "#{uri.scheme}://#{uri.host}:#{uri.port}#{base_path}" )
end

Instance Method Details

#readObject



61
62
63
# File 'lib/preproc.rb', line 61

def read
  preproc( @text )
end