Class: Magika::FileType

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

Constant Summary collapse

CONTENT_TYPES_PATH =
File.join(ASSETS_DIR, "content_types_kb.min.json")
CONTENT_TYPES =
JSON.load_file(CONTENT_TYPES_PATH, symbolize_names: true)
MEDIUM_CONFIDENCE_THRESHOLD =
THRESHOLDS =

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(label, score) ⇒ FileType

Returns a new instance of FileType.



121
122
123
124
125
126
# File 'lib/magika.rb', line 121

def initialize(label, score)
  @inferred_label = label
  @score = score
  @overwritten = nil
  @content_type = nil
end

Instance Attribute Details

#scoreObject (readonly)

Returns the value of attribute score.



119
120
121
# File 'lib/magika.rb', line 119

def score
  @score
end

Instance Method Details

#inspectObject



143
144
145
# File 'lib/magika.rb', line 143

def inspect
  "#<#{self.class} label=#{label} score=#{score} #{mime_type} #{description.dump} (#{group})>"
end

#labelObject



128
129
130
131
# File 'lib/magika.rb', line 128

def label
  content_type
  @overwritten || @inferred_label
end

#text?Boolean

Returns:

  • (Boolean)


139
140
141
# File 'lib/magika.rb', line 139

def text?
  content_type[:is_text]
end