Class: Licensee::Project::File
- Inherits:
-
Object
- Object
- Licensee::Project::File
- Defined in:
- lib/licensee/project_file.rb
Direct Known Subclasses
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.
8 9 10 11 12 |
# File 'lib/licensee/project_file.rb', line 8 def initialize(content, filename = nil) @content = content @content.encode!(Encoding::UTF_8, :invalid => :replace, :undef => :replace, :replace => "") @filename = filename end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
6 7 8 |
# File 'lib/licensee/project_file.rb', line 6 def content @content end |
#filename ⇒ Object (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
#confidence ⇒ Object
Returns the percent confident with the match
19 20 21 |
# File 'lib/licensee/project_file.rb', line 19 def confidence matcher && matcher.confidence end |
#license ⇒ Object Also known as: match
23 24 25 |
# File 'lib/licensee/project_file.rb', line 23 def license matcher && matcher.match end |
#matcher ⇒ Object
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 |