module CiteProc::Asset
Attributes
asset[R]
location[R]
to_s[R]
Public Class Methods
included(base)
click to toggle source
# File lib/citeproc/assets.rb, line 5 def self.included(base) base.extend(ClassMethods) end
Public Instance Methods
inspect()
click to toggle source
# File lib/citeproc/assets.rb, line 51 def inspect "#<CiteProc::#{self.class.name} #{name}>" end
name()
click to toggle source
# File lib/citeproc/assets.rb, line 45 def name File.basename(location, self.class.extension).sub(Regexp.new("^#{self.class.prefix}"), '') end
open(input)
click to toggle source
# File lib/citeproc/assets.rb, line 15 def open(input) case when input.respond_to?(:read) @location = nil @asset = input.read when input.to_s =~ /^\s*</ @location = nil @asset = input.to_s.dup else case when File.exist?(input) @location = input when File.exist?(self.class.extend_name(input)) @location = self.class.extend_name(input) when File.exist?(self.class.extend_path(input)) @location = self.class.extend_path(input) else @location = input end Kernel.open(@location, 'r:UTF-8') do |io| @asset = io.read end end self rescue => e raise ArgumentError, "failed to open asset #@location (#{input.inspect}): #{e.message}" end
open?()
click to toggle source
# File lib/citeproc/assets.rb, line 11 def open? !asset.nil? end