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::Base>
Returns all parsed objects as code object proxies.
-
#filter!(options) ⇒ void
Filters the list based on the settings in
options
. -
#find(fullname) ⇒ CodeObject::Proxy::Base
Returns the object with the given
fullname
. -
#initialize(objects) ⇒ Objects
constructor
A new instance of Objects.
-
#starting_with(partial_name) ⇒ Array<CodeObject::Proxy::Base>
Returns all objects where the
fullname
starts_with the givenpartial_name
.
Constructor Details
#initialize(objects) ⇒ Objects
Returns a new instance of Objects.
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/inch/codebase/objects.rb', line 17 def initialize(objects) list = objects.map do |o| proxy = CodeObject::Proxy.for(o) proxy.object_lookup = self proxy 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::Base>
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::Base>
Returns all parsed objects as code object proxies
35 36 37 |
# File 'lib/inch/codebase/objects.rb', line 35 def all @list end |
#filter!(options) ⇒ void
This method returns an undefined value.
Filters the list based on the settings in options
69 70 71 72 |
# File 'lib/inch/codebase/objects.rb', line 69 def filter!() @list = ObjectsFilter.new(all, ).objects index_by_fullname end |
#find(fullname) ⇒ CodeObject::Proxy::Base
Returns the object with the given fullname
48 49 50 |
# File 'lib/inch/codebase/objects.rb', line 48 def find(fullname) @by_fullname[fullname] end |
#starting_with(partial_name) ⇒ Array<CodeObject::Proxy::Base>
Returns all objects where the fullname
starts_with the given partial_name
62 63 64 |
# File 'lib/inch/codebase/objects.rb', line 62 def starting_with(partial_name) all.select { |o| o.fullname.start_with?(partial_name) } end |