Class: SourceFile

Inherits:
Object
  • Object
show all
Extended by:
Logging
Defined in:
lib/sourcefile.rb

Overview

SourceFile defines objects, which represent the original html-files,

to be processed by the slideshow-generator. Each SourceFile-object will 
provide a few details about the contents and location of 1 such file.

Constant Summary collapse

@@log =
self::init_logger

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logging

init_logger, log_level=, log_target=

Methods included from File_Checking

file_check, #file_check, last_mime_type, magic_check, mime_check

Constructor Details

#initialize(path, options) ⇒ SourceFile

Returns a new instance of SourceFile.



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/sourcefile.rb', line 44

def initialize(path, options)
  @log = @@log
  @log.debug(format("initializing SourceFile for %s ", path)) if @log
  @log.debug('options are ' << options.to_s)

  @path = path
  @formats = options.formats

  # file extension
  local = 'files' == options.source_type 
  @file_ext = ((local || options.merge) ? '.html' : File.extname(@path))

  # file name without path or extension
  @file_name = File.basename(@path.gsub("\\", '/'), @file_ext)

  # directory where the original html-file is found 
  @dirname = File.dirname(@path)

  # All references to image-files, found in the file
  @images = Array.new 

  # number of images, found 
  @img_count = 0

  # title of the original page
  # or the final slide show file
  @title = nil
  @title = options.title if options.title && !options.title.empty?

  @title.strip! if @title

  # scan sub-directories (local image-files, only)
  @recursive = options.recursive
  @log.debug("recursive ? " << @recursive.to_s)
  @log.debug(format("files from %s", (local ? 'directory' : 'html')) ) if @log
  # read pages or files, analyze, set image-references and title
  if(local)
    read_dir
  elsif(options.merge)
    read_files
  else
    read_file
  end
  @log.debug("sourcefile initialized: " + @path) if @log
end

Instance Attribute Details

#dirnameObject (readonly)

Returns the value of attribute dirname.



42
43
44
# File 'lib/sourcefile.rb', line 42

def dirname
  @dirname
end

#file_extObject (readonly)

Returns the value of attribute file_ext.



42
43
44
# File 'lib/sourcefile.rb', line 42

def file_ext
  @file_ext
end

#file_nameObject (readonly)

Returns the value of attribute file_name.



42
43
44
# File 'lib/sourcefile.rb', line 42

def file_name
  @file_name
end

#imagesObject (readonly)

Returns the value of attribute images.



42
43
44
# File 'lib/sourcefile.rb', line 42

def images
  @images
end

#img_countObject (readonly)

Returns the value of attribute img_count.



42
43
44
# File 'lib/sourcefile.rb', line 42

def img_count
  @img_count
end

#titleObject (readonly)

Returns the value of attribute title.



42
43
44
# File 'lib/sourcefile.rb', line 42

def title
  @title
end