Class: Inch::Codebase::Objects
- Inherits:
-
Object
- Object
- Inch::Codebase::Objects
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Defined in:
- lib/inch/codebase/objects.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#all ⇒ Array<CodeObject::Proxy>
Returns all parsed objects as code object proxies.
-
#filter!(options) ⇒ void
Filters the list based on the settings in
options
. -
#find(fullname) ⇒ CodeObject::Proxy
Returns the object with the given
fullname
. -
#initialize(language, objects) ⇒ Objects
constructor
A new instance of Objects.
-
#starting_with(partial_name) ⇒ Array<CodeObject::Proxy>
Returns all objects where the
fullname
starts_with the givenpartial_name
.
Constructor Details
#initialize(language, objects) ⇒ Objects
Returns a new instance of Objects.
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/inch/codebase/objects.rb', line 17 def initialize(language, objects) list = objects.map do |code_object| Codebase::Object.new(language, code_object, self) end @list = list index_by_fullname # the @list has to be set for the priority sorting # since the priority needs the object_lookup, which # in turn depends on @list - it's a crazy world @list = self.class.sort_by_priority(@list) end |
Class Method Details
.sort_by_priority(objects) ⇒ Array<CodeObject::Proxy>
11 12 13 14 15 |
# File 'lib/inch/codebase/objects.rb', line 11 def self.sort_by_priority(objects) objects.sort_by do |o| [o.priority, o.score, o.fullname.size] end.reverse end |
Instance Method Details
#all ⇒ Array<CodeObject::Proxy>
Returns all parsed objects as code object proxies
33 34 35 |
# File 'lib/inch/codebase/objects.rb', line 33 def all @list end |
#filter!(options) ⇒ void
This method returns an undefined value.
Filters the list based on the settings in options
67 68 69 70 |
# File 'lib/inch/codebase/objects.rb', line 67 def filter!() @list = ObjectsFilter.new(all, ).objects index_by_fullname end |
#find(fullname) ⇒ CodeObject::Proxy
Returns the object with the given fullname
46 47 48 |
# File 'lib/inch/codebase/objects.rb', line 46 def find(fullname) @by_fullname[fullname] end |
#starting_with(partial_name) ⇒ Array<CodeObject::Proxy>
Returns all objects where the fullname
starts_with the given partial_name
60 61 62 |
# File 'lib/inch/codebase/objects.rb', line 60 def starting_with(partial_name) all.select { |o| o.fullname.start_with?(partial_name) } end |