Class: AdLint::Source
- Inherits:
-
Object
- Object
- AdLint::Source
- Extended by:
- Pluggable
- Defined in:
- lib/adlint/source.rb
Overview
DESCRIPTION
Target source file.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#fpath ⇒ Object
readonly
VALUE String – The path name of this source file.
-
#included_at ⇒ Object
readonly
Returns the value of attribute included_at.
Instance Method Summary collapse
- #analysis_target?(traits) ⇒ Boolean
-
#initialize(fpath, fenc, included_at = Location.new) ⇒ Source
constructor
DESCRIPTION Constructs a target source file.
-
#open(&block) ⇒ Object
DESCRIPTION Opens the target source file.
- #system_header? ⇒ Boolean
-
#to_s ⇒ Object
DESCRIPTION Converts this source content into string.
- #user_header? ⇒ Boolean
Methods included from Pluggable
Constructor Details
#initialize(fpath, fenc, included_at = Location.new) ⇒ Source
DESCRIPTION
Constructs a target source file.
PARAMETER
- fpath
-
Pathname – Path name of the target source file.
- content
-
String – Source content.
47 48 49 50 51 52 |
# File 'lib/adlint/source.rb', line 47 def initialize(fpath, fenc, included_at = Location.new) @fpath = fpath @fenc = fenc @included_at = included_at @content = nil end |
Instance Attribute Details
#fpath ⇒ Object (readonly)
VALUE
String – The path name of this source file.
62 63 64 |
# File 'lib/adlint/source.rb', line 62 def fpath @fpath end |
#included_at ⇒ Object (readonly)
Returns the value of attribute included_at.
64 65 66 |
# File 'lib/adlint/source.rb', line 64 def included_at @included_at end |
Instance Method Details
#analysis_target?(traits) ⇒ Boolean
74 75 76 |
# File 'lib/adlint/source.rb', line 74 def analysis_target?(traits) Location.new(@fpath).in_analysis_target?(traits) end |
#open(&block) ⇒ Object
DESCRIPTION
Opens the target source file.
PARAMETER
- block
-
Proc – Yieldee block.
83 84 85 86 87 88 89 |
# File 'lib/adlint/source.rb', line 83 def open(&block) @content ||= read_content(@fpath) io = StringIO.new(@content) yield(io) ensure io && io.close end |
#system_header? ⇒ Boolean
70 71 72 |
# File 'lib/adlint/source.rb', line 70 def system_header? false end |
#to_s ⇒ Object
DESCRIPTION
Converts this source content into string.
RETURN VALUE
String – Content of this source file.
96 97 98 |
# File 'lib/adlint/source.rb', line 96 def to_s @content ||= read_content(@fpath) end |
#user_header? ⇒ Boolean
66 67 68 |
# File 'lib/adlint/source.rb', line 66 def user_header? false end |