Class: TypeBalancer::TypeExtractor
- Inherits:
-
Object
- Object
- TypeBalancer::TypeExtractor
- Defined in:
- lib/type_balancer/type_extractor.rb
Instance Method Summary collapse
- #extract_types(collection) ⇒ Object
- #group_by_type(collection) ⇒ Object
-
#initialize(type_field) ⇒ TypeExtractor
constructor
A new instance of TypeExtractor.
Constructor Details
#initialize(type_field) ⇒ TypeExtractor
Returns a new instance of TypeExtractor.
5 6 7 |
# File 'lib/type_balancer/type_extractor.rb', line 5 def initialize(type_field) @type_field = type_field end |
Instance Method Details
#extract_types(collection) ⇒ Object
9 10 11 |
# File 'lib/type_balancer/type_extractor.rb', line 9 def extract_types(collection) collection.map { |item| get_type(item) }.uniq end |
#group_by_type(collection) ⇒ Object
13 14 15 |
# File 'lib/type_balancer/type_extractor.rb', line 13 def group_by_type(collection) collection.group_by { |item| get_type(item) } end |