Class: Licensee::Project::File

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

Direct Known Subclasses

LicenseFile, PackageInfo

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content, filename = nil) ⇒ File

Returns a new instance of File.



8
9
10
11
12
# File 'lib/licensee/project_file.rb', line 8

def initialize(content, filename = nil)
  @content = content
  @content.force_encoding(Encoding::UTF_8)
  @filename = filename
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



6
7
8
# File 'lib/licensee/project_file.rb', line 6

def content
  @content
end

#filenameObject (readonly) Also known as: path

Returns the value of attribute filename.



6
7
8
# File 'lib/licensee/project_file.rb', line 6

def filename
  @filename
end

Instance Method Details

#confidenceObject

Returns the percent confident with the match



19
20
21
# File 'lib/licensee/project_file.rb', line 19

def confidence
  matcher && matcher.confidence
end

#licenseObject Also known as: match



23
24
25
# File 'lib/licensee/project_file.rb', line 23

def license
  matcher && matcher.match
end

#matcherObject



14
15
16
# File 'lib/licensee/project_file.rb', line 14

def matcher
  @matcher ||= possible_matchers.map { |m| m.new(self) }.find { |m| m.match }
end