Class: Lemon::SourceParser::Scope
- Inherits:
-
Object
- Object
- Lemon::SourceParser::Scope
- Includes:
- Enumerable
- Defined in:
- lib/lemon/coverage/source_parser.rb
Overview
A Scope is a Module or Class, and may contain other scopes.
Instance Attribute Summary collapse
-
#class_methods ⇒ Object
Returns the value of attribute class_methods.
-
#comment ⇒ Object
Returns the value of attribute comment.
-
#instance_methods ⇒ Object
Returns the value of attribute instance_methods.
-
#name ⇒ Object
Returns the value of attribute name.
-
#parent ⇒ Object
Returns the value of attribute parent.
-
#scopes ⇒ Object
Returns the value of attribute scopes.
Instance Method Summary collapse
- #[](scope) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(name, comment = '', instance_methods = [], class_methods = []) ⇒ Scope
constructor
A new instance of Scope.
- #inspect ⇒ Object
- #keys ⇒ Object
- #target ⇒ Object
- #to_s ⇒ Object
- #to_units ⇒ Object
Constructor Details
#initialize(name, comment = '', instance_methods = [], class_methods = []) ⇒ Scope
Returns a new instance of Scope.
184 185 186 187 188 189 190 |
# File 'lib/lemon/coverage/source_parser.rb', line 184 def initialize(name, comment='', instance_methods=[], class_methods=[]) @name = name @comment = comment @instance_methods = instance_methods @class_methods = class_methods @scopes = {} end |
Instance Attribute Details
#class_methods ⇒ Object
Returns the value of attribute class_methods.
178 179 180 |
# File 'lib/lemon/coverage/source_parser.rb', line 178 def class_methods @class_methods end |
#comment ⇒ Object
Returns the value of attribute comment.
178 179 180 |
# File 'lib/lemon/coverage/source_parser.rb', line 178 def comment @comment end |
#instance_methods ⇒ Object
Returns the value of attribute instance_methods.
178 179 180 |
# File 'lib/lemon/coverage/source_parser.rb', line 178 def instance_methods @instance_methods end |
#name ⇒ Object
Returns the value of attribute name.
178 179 180 |
# File 'lib/lemon/coverage/source_parser.rb', line 178 def name @name end |
#parent ⇒ Object
Returns the value of attribute parent.
180 181 182 |
# File 'lib/lemon/coverage/source_parser.rb', line 180 def parent @parent end |
#scopes ⇒ Object
Returns the value of attribute scopes.
182 183 184 |
# File 'lib/lemon/coverage/source_parser.rb', line 182 def scopes @scopes end |
Instance Method Details
#[](scope) ⇒ Object
192 193 194 |
# File 'lib/lemon/coverage/source_parser.rb', line 192 def [](scope) @scopes[scope] end |
#each(&block) ⇒ Object
200 201 202 |
# File 'lib/lemon/coverage/source_parser.rb', line 200 def each(&block) @scopes.each(&block) end |
#inspect ⇒ Object
208 209 210 211 212 213 214 |
# File 'lib/lemon/coverage/source_parser.rb', line 208 def inspect scopes = @scopes.keys.join(', ') imethods = @instance_methods.inspect cmethods = @class_methods.inspect "<#{name} scopes:[#{scopes}] :#{cmethods}: ##{imethods}#>" end |
#keys ⇒ Object
196 197 198 |
# File 'lib/lemon/coverage/source_parser.rb', line 196 def keys @scopes.keys end |
#target ⇒ Object
217 218 219 220 221 222 223 |
# File 'lib/lemon/coverage/source_parser.rb', line 217 def target if parent parent.target.const_get(name) else Object.const_get(name) end end |
#to_s ⇒ Object
204 205 206 |
# File 'lib/lemon/coverage/source_parser.rb', line 204 def to_s inspect end |
#to_units ⇒ Object
226 227 228 229 230 231 232 233 234 235 236 237 238 |
# File 'lib/lemon/coverage/source_parser.rb', line 226 def to_units units = [] @instance_methods.each do |imethod| units << Snapshot::Unit.new(target, imethod, :singleton=>false) end @class_methods.each do |imethod| units << Snapshot::Unit.new(target, imethod, :singleton=>true) end @scopes.each do |name, scope| units.concat(scope.to_units) end units end |