Class: Inch::Codebase::Object
- Inherits:
-
Object
- Object
- Inch::Codebase::Object
- Extended by:
- Forwardable
- Defined in:
- lib/inch/codebase/object.rb
Overview
An object that holds a code_object as well as it’s evaluation and exposes shortcut methods to the commonly asked members of both.
Instance Attribute Summary collapse
-
#code_object ⇒ Object
readonly
Returns the value of attribute code_object.
- #grade ⇒ Grade
- #language ⇒ String readonly
Instance Method Summary collapse
- #evaluation ⇒ Object
-
#initialize(language, code_object, object_lookup) ⇒ Object
constructor
A new instance of Object.
- #method_missing(name, *args, &block) ⇒ Object
Constructor Details
#initialize(language, code_object, object_lookup) ⇒ Object
Returns a new instance of Object.
30 31 32 33 34 |
# File 'lib/inch/codebase/object.rb', line 30 def initialize(language, code_object, object_lookup) @language = language @code_object = CodeObject::Proxy.for(language, code_object, object_lookup) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/inch/codebase/object.rb', line 47 def method_missing(name, *args, &block) if code_object.respond_to?(name) self.class.class_eval <<-RUBY def #{name}(*args, &block) code_object.#{name}(*args, &block) end RUBY code_object.send(name, *args, &block) else super end end |
Instance Attribute Details
#code_object ⇒ Object (readonly)
Returns the value of attribute code_object.
11 12 13 |
# File 'lib/inch/codebase/object.rb', line 11 def code_object @code_object end |
#grade ⇒ Grade
41 42 43 44 45 |
# File 'lib/inch/codebase/object.rb', line 41 def grade @grade ||= Evaluation.new_grade_lists.find do |range| range.scores.include?(score) end.grade end |
#language ⇒ String (readonly)
14 15 16 |
# File 'lib/inch/codebase/object.rb', line 14 def language @language end |
Instance Method Details
#evaluation ⇒ Object
36 37 38 |
# File 'lib/inch/codebase/object.rb', line 36 def evaluation @evaluation ||= Evaluation::Proxy.for(@language, self) end |