class Ansei::FileInfo

File information for Ansei

Attributes

file[R]
type[R]

Public Class Methods

new(type, file) click to toggle source

Initialize a new FileInfo object

type - 'standardized' type of file file - filename for file

Returns a new FileInfo object

# File lib/ansei/fileinfo.rb, line 12
def initialize(type, file)
  @type = type
  @file = file
end

Public Instance Methods

build() click to toggle source

Get the file's build directory

Returns a string

# File lib/ansei/fileinfo.rb, line 20
def build
  Ansei.config[:directories][type].last
end
destination() click to toggle source

Get the file's destination filename

Returns a string

# File lib/ansei/fileinfo.rb, line 27
def destination
  dir = Ansei.config[:directories][:build]

  "#{dir}/#{name}"
end
ext() click to toggle source

Get the file's extension

Returns a string

# File lib/ansei/fileinfo.rb, line 36
def ext
  Utils.file_ext(file, true)
end
exts() click to toggle source

Get the destination file extension, and all other possible extensions for its type

Returns an array

# File lib/ansei/fileinfo.rb, line 44
def exts
  Ansei.config[:extensions][type]
end
name() click to toggle source

Get the 'basename' for the file

Returns a string

# File lib/ansei/fileinfo.rb, line 51
def name
  name = file.sub("#{source}/", '')
  name = name.sub(Utils.file_ext(file), '')

  name = Utils.string_urlify(name) if type == :markdown
  name = "#{build}/#{name}.#{exts.first}"

  name.sub(/\A\//, '')
end
source() click to toggle source

Get the file's source directory

Returns a string

# File lib/ansei/fileinfo.rb, line 64
def source
  Ansei.config[:directories][type].first
end