Class: EacFs::FileInfo

Inherits:
Object show all
Defined in:
lib/eac_fs/file_info.rb

Constant Summary collapse

UNKNOWN_CONTENT_TYPE_STRING =
'application/octet-stream'
UNKNOWN_CONTENT_TYPE =
::ContentType.parse(UNKNOWN_CONTENT_TYPE_STRING)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Object

Parameters:



20
21
22
# File 'lib/eac_fs/file_info.rb', line 20

common_constructor :path do
  self.path = path.to_pathname
end

Instance Attribute Details

#pathPathname (readonly)

Returns:



# File 'lib/eac_fs/file_info.rb', line 15

Instance Method Details

#descriptionString

Returns:

  • (String)


27
28
29
# File 'lib/eac_fs/file_info.rb', line 27

def description
  magic
end

#magic(*flags) ⇒ String

Returns:

  • (String)


37
38
39
# File 'lib/eac_fs/file_info.rb', line 37

def magic(*flags)
  ::FileMagic.new(*flags).file(path.to_path)
end

#open?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/eac_fs/file_info.rb', line 32

def open?
  ::EacFs::Executables.lsof.command(path).execute.fetch(:exit_code).zero?
end