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



31
32
33
34
# File 'lib/pandocomatic/input.rb', line 31

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

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



26
27
28
# File 'lib/pandocomatic/input.rb', line 26

def errors
  @errors
end

Instance Method Details

#absolute_pathObject

The absolute path to this Input

Returns:

  • String



39
40
41
# File 'lib/pandocomatic/input.rb', line 39

def absolute_path
  File.absolute_path @input_files.first
end

#baseObject

The base name of this Input

Returns:

  • String



46
47
48
# File 'lib/pandocomatic/input.rb', line 46

def base
  File.basename @input_files.first
end

#directory?Boolean

Is this input a directory?

Returns:

  • (Boolean)

    Boolean



60
61
62
# File 'lib/pandocomatic/input.rb', line 60

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

#errors?Boolean

Does this input have encountered any errors?

Returns:

  • (Boolean)

    Boolean



67
68
69
# File 'lib/pandocomatic/input.rb', line 67

def errors?
  !@errors.empty?
end

#nameObject

The name of this input

Returns:

  • String



53
54
55
# File 'lib/pandocomatic/input.rb', line 53

def name
  @input_files.first
end

#to_sObject

A string representation of this Input

Returns:

  • String



74
75
76
# File 'lib/pandocomatic/input.rb', line 74

def to_s
  name
end