Module: LintFu::Eidos
- Defined in:
- lib/lint_fu/eidos.rb
Overview
An eidos (plural: eide) holds information about a Ruby class, module or other relevant piece of code. The name comes from Plato’s theory of forms; the eidos is the universal abstraction of an entire class of objects.
Eide are built during the first pass of static analysis by parsing all source files in the project. On the second pass, the checkers parse selected bits of code, using the eide to better understand the code they are parsing.
Constant Summary collapse
- VALID_SEXPS =
Set.new([:class, :module])
Instance Attribute Summary collapse
-
#modeled_class_name ⇒ Object
readonly
Returns the value of attribute modeled_class_name.
-
#modeled_class_superclass_name ⇒ Object
readonly
Returns the value of attribute modeled_class_superclass_name.
-
#parent_eidos ⇒ Object
Returns the value of attribute parent_eidos.
-
#parse_tree ⇒ Object
readonly
Returns the value of attribute parse_tree.
Instance Method Summary collapse
-
#initialize(sexp, namespace = nil) ⇒ Object
- sexp
- :class, <classname>, <superclass|nil>, <CLASS DEFS>
- namespace
-
Array of enclosing module names for this class.
-
#to_s ⇒ Object
Have a pretty string representation.
Instance Attribute Details
#modeled_class_name ⇒ Object (readonly)
Returns the value of attribute modeled_class_name.
11 12 13 |
# File 'lib/lint_fu/eidos.rb', line 11 def modeled_class_name @modeled_class_name end |
#modeled_class_superclass_name ⇒ Object (readonly)
Returns the value of attribute modeled_class_superclass_name.
11 12 13 |
# File 'lib/lint_fu/eidos.rb', line 11 def modeled_class_superclass_name @modeled_class_superclass_name end |
#parent_eidos ⇒ Object
Returns the value of attribute parent_eidos.
10 11 12 |
# File 'lib/lint_fu/eidos.rb', line 10 def parent_eidos @parent_eidos end |
#parse_tree ⇒ Object (readonly)
Returns the value of attribute parse_tree.
11 12 13 |
# File 'lib/lint_fu/eidos.rb', line 11 def parse_tree @parse_tree end |
Instance Method Details
#initialize(sexp, namespace = nil) ⇒ Object
- sexp
- :class, <classname>, <superclass|nil>, <CLASS DEFS>
- namespace
-
Array of enclosing module names for this class
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/lint_fu/eidos.rb', line 17 def initialize(sexp, namespace=nil) unless VALID_SEXPS.include?(sexp[0]) raise ArgumentError, "Must be constructed from a class-definition Sexp" end @sexp = sexp if namespace @modeled_class_name = namespace.join('::') + (namespace.empty? ? '' : '::') + sexp[1].to_s else @modeled_class_name = sexp[1] end end |
#to_s ⇒ Object
Have a pretty string representation
31 32 33 |
# File 'lib/lint_fu/eidos.rb', line 31 def to_s "<<model of #{self.modeled_class_name}>>" end |