Class: Trax::Core::FS::Listing

Inherits:
Pathname
  • Object
show all
Defined in:
lib/trax/core/fs.rb

Instance Method Summary collapse

Instance Method Details

#bitmap?Boolean

Returns:

  • (Boolean)


204
205
206
# File 'lib/trax/core/fs.rb', line 204

def bitmap?
  return sample[0,2] == "MB"
end

#copy_to(destination) ⇒ Object



208
209
210
# File 'lib/trax/core/fs.rb', line 208

def copy_to(destination)
  ::FileUtils.cp(self, destination)
end

#gif?Boolean

Returns:

  • (Boolean)


215
216
217
# File 'lib/trax/core/fs.rb', line 215

def gif?
  return sample[0,4] == "GIF8"
end

#image?Boolean

Returns:

  • (Boolean)


227
228
229
# File 'lib/trax/core/fs.rb', line 227

def image?
  bitmap? || gif? || jpeg?
end

#jpeg?Boolean

Returns:

  • (Boolean)


231
232
233
# File 'lib/trax/core/fs.rb', line 231

def jpeg?
  return sample[0,4] == "\xff\xd8\xff\xe0"
end

#nameObject



219
220
221
# File 'lib/trax/core/fs.rb', line 219

def name
  basename.to_s
end

#name_without_extensionObject



223
224
225
# File 'lib/trax/core/fs.rb', line 223

def name_without_extension
  name.split('.')[0]
end

#sampleObject



235
236
237
238
239
240
241
242
# File 'lib/trax/core/fs.rb', line 235

def sample
  @sample ||= begin
    f = ::File.open(self.to_s, 'rb')
    result = f.read(9)
    f.close
    result
  end
end