Class: SyntaxTree::CLI::FileItem

Inherits:
Object
  • Object
show all
Defined in:
lib/syntax_tree/cli.rb

Overview

An item of work that corresponds to a file to be processed.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filepath) ⇒ FileItem

Returns a new instance of FileItem.



44
45
46
# File 'lib/syntax_tree/cli.rb', line 44

def initialize(filepath)
  @filepath = filepath
end

Instance Attribute Details

#filepathObject (readonly)

Returns the value of attribute filepath.



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

def filepath
  @filepath
end

Instance Method Details

#handlerObject



48
49
50
# File 'lib/syntax_tree/cli.rb', line 48

def handler
  HANDLERS[File.extname(filepath)]
end

#sourceObject



52
53
54
# File 'lib/syntax_tree/cli.rb', line 52

def source
  handler.read(filepath)
end

#writable?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/syntax_tree/cli.rb', line 56

def writable?
  File.writable?(filepath)
end