Class: Pandocomatic::Input

Inherits:
Object
  • Object
show all
Defined in:
lib/pandocomatic/input.rb

Overview

Generic class to handle input files and directories in a general manner.

Direct Known Subclasses

MultipleFilesInput

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input) ⇒ Input

Create a new Input

Parameters:

  • input (String[])

    a list of input files



29
30
31
32
# File 'lib/pandocomatic/input.rb', line 29

def initialize(input)
  @input_files = input
  @errors = []
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



24
25
26
# File 'lib/pandocomatic/input.rb', line 24

def errors
  @errors
end

Instance Method Details

#absolute_pathObject

The absolute path to this Input

Returns:

  • String



37
38
39
# File 'lib/pandocomatic/input.rb', line 37

def absolute_path
  File.absolute_path @input_files.first
end

#baseObject

The base name of this Input

Returns:

  • String



44
45
46
# File 'lib/pandocomatic/input.rb', line 44

def base
  File.basename @input_files.first
end

#directory?Boolean

Is this input a directory?

Returns:

  • (Boolean)

    Boolean



58
59
60
# File 'lib/pandocomatic/input.rb', line 58

def directory?
  File.directory? @input_files.first
end

#errors?Boolean

Does this input have encountered any errors?

Returns:

  • (Boolean)

    Boolean



65
66
67
# File 'lib/pandocomatic/input.rb', line 65

def errors?
  !@errors.empty?
end

#nameObject

The name of this input

Returns:

  • String



51
52
53
# File 'lib/pandocomatic/input.rb', line 51

def name
  @input_files.first
end

#to_sObject

A string representation of this Input

Returns:

  • String



72
73
74
# File 'lib/pandocomatic/input.rb', line 72

def to_s
  name
end