Class: Licensee::Project::File
- Inherits:
-
Object
- Object
- Licensee::Project::File
- Defined in:
- lib/licensee/project_file.rb
Direct Known Subclasses
Constant Summary collapse
- ENCODING =
Encoding::UTF_8
- ENCODING_OPTIONS =
{ invalid: :replace, undef: :replace, replace: '' }.freeze
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#filename ⇒ Object
(also: #path)
readonly
Returns the value of attribute filename.
Instance Method Summary collapse
-
#confidence ⇒ Object
Returns the percent confident with the match.
-
#initialize(content, filename = nil) ⇒ File
constructor
A new instance of File.
- #license ⇒ Object (also: #match)
- #matcher ⇒ Object
Constructor Details
#initialize(content, filename = nil) ⇒ File
Returns a new instance of File.
13 14 15 16 17 |
# File 'lib/licensee/project_file.rb', line 13 def initialize(content, filename = nil) @content = content @content.encode!(ENCODING, ENCODING_OPTIONS) @filename = filename end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
4 5 6 |
# File 'lib/licensee/project_file.rb', line 4 def content @content end |
#filename ⇒ Object (readonly) Also known as: path
Returns the value of attribute filename.
4 5 6 |
# File 'lib/licensee/project_file.rb', line 4 def filename @filename end |
Instance Method Details
#confidence ⇒ Object
Returns the percent confident with the match
24 25 26 |
# File 'lib/licensee/project_file.rb', line 24 def confidence matcher && matcher.confidence end |
#license ⇒ Object Also known as: match
28 29 30 |
# File 'lib/licensee/project_file.rb', line 28 def license matcher && matcher.match end |
#matcher ⇒ Object
19 20 21 |
# File 'lib/licensee/project_file.rb', line 19 def matcher @matcher ||= possible_matchers.map { |m| m.new(self) }.find(&:match) end |