Class: SCNR::Introspector::Coverage::Resource::Line
- Inherits:
-
Object
- Object
- SCNR::Introspector::Coverage::Resource::Line
- Defined in:
- lib/scnr/introspector/coverage/resource/line.rb
Instance Attribute Summary collapse
-
#content ⇒ String
Line content.
-
#hits ⇒ nil, Integer
Amount of times this line was executed:.
-
#number ⇒ Integer
Line number.
-
#resource ⇒ Resource
Resource containing ‘self`.
Instance Method Summary collapse
- #hit(count) ⇒ Object
-
#hit? ⇒ Bool
‘true` if the line was executed, `false` otherwise.
-
#initialize(options = {}) ⇒ Line
constructor
A new instance of Line.
-
#missed? ⇒ Bool
‘true` if the line wasn’t executed, ‘false` otherwise.
-
#skipped? ⇒ Bool
‘true` if the line is irrelevant to the coverage, `false` otherwise.
-
#state ⇒ Symbol
-
‘:skipped` if #skipped?.
-
Constructor Details
#initialize(options = {}) ⇒ Line
Returns a new instance of Line.
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/scnr/introspector/coverage/resource/line.rb', line 33 def initialize( = {} ) @resource = [:resource] fail ArgumentError, 'Missing :resource' if !@resource @number = [:number] fail ArgumentError, 'Missing :number' if !@number.is_a?( Integer ) @content = [:content] fail ArgumentError, 'Missing :content' if !@content @hits = [:hits] end |
Instance Attribute Details
#content ⇒ String
Returns Line content.
14 15 16 |
# File 'lib/scnr/introspector/coverage/resource/line.rb', line 14 def content @content end |
#hits ⇒ nil, Integer
26 27 28 |
# File 'lib/scnr/introspector/coverage/resource/line.rb', line 26 def hits @hits end |
#number ⇒ Integer
Returns Line number.
10 11 12 |
# File 'lib/scnr/introspector/coverage/resource/line.rb', line 10 def number @number end |
#resource ⇒ Resource
Returns Resource containing ‘self`.
18 19 20 |
# File 'lib/scnr/introspector/coverage/resource/line.rb', line 18 def resource @resource end |
Instance Method Details
#hit(count) ⇒ Object
76 77 78 79 80 81 |
# File 'lib/scnr/introspector/coverage/resource/line.rb', line 76 def hit( count ) return if !count @hits ||= 0 @hits += count end |
#hit? ⇒ Bool
Returns ‘true` if the line was executed, `false` otherwise.
60 61 62 |
# File 'lib/scnr/introspector/coverage/resource/line.rb', line 60 def hit? @hits.to_i > 0 end |
#missed? ⇒ Bool
Returns ‘true` if the line wasn’t executed, ‘false` otherwise.
54 55 56 |
# File 'lib/scnr/introspector/coverage/resource/line.rb', line 54 def missed? @hits == 0 end |
#skipped? ⇒ Bool
Returns ‘true` if the line is irrelevant to the coverage, `false` otherwise.
48 49 50 |
# File 'lib/scnr/introspector/coverage/resource/line.rb', line 48 def skipped? @hits.nil? end |