Class: CommentExtractor::File
- Inherits:
-
File
- Object
- File
- CommentExtractor::File
- Defined in:
- lib/comment_extractor/file.rb
Constant Summary collapse
- THRESHOLD_BINARY =
0.3
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#shebang ⇒ Object
Returns the value of attribute shebang.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
7 8 9 |
# File 'lib/comment_extractor/file.rb', line 7 def content @content end |
#shebang ⇒ Object
Returns the value of attribute shebang.
7 8 9 |
# File 'lib/comment_extractor/file.rb', line 7 def shebang @shebang end |
Class Method Details
.binary?(file_path) ⇒ Boolean
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/comment_extractor/file.rb', line 18 def self.binary?(file_path) header = File.read(file_path, File.stat(file_path).blksize) || nil if header.nil? || header.empty? false else chars = header.chars (chars.grep(' '..'~').size / chars.size.to_f) <= THRESHOLD_BINARY end end |