Module: SwotCollectionMethods
- Included in:
- Swot
- Defined in:
- lib/swot/collection_methods.rb
Overview
Module for methods that act on the entire Swot dataset.
Instance Method Summary collapse
-
#all_domains ⇒ Object
Returns an array of domain strings.
-
#each_domain ⇒ Object
Yields a Swot instance for every domain under lib/domains.
Instance Method Details
#all_domains ⇒ Object
Returns an array of domain strings.
6 7 8 |
# File 'lib/swot/collection_methods.rb', line 6 def all_domains each_domain.map(&:to_s) end |
#each_domain ⇒ Object
Yields a Swot instance for every domain under lib/domains. Does not
include blacklisted or ACADEMIC_TLDS domains.
returns a Enumerator object with Swot instances if no block is given
14 15 16 17 18 19 |
# File 'lib/swot/collection_methods.rb', line 14 def each_domain return to_enum(:each_domain) unless block_given? Pathname.glob(Pathname.new(Swot.domains_path).join('**/*.txt')) do |path| yield(Swot.from_path(path)) end end |