Class: ChannelGrouping::Source
- Inherits:
-
Object
- Object
- ChannelGrouping::Source
- Defined in:
- lib/channel_grouping/source.rb
Constant Summary collapse
- CONFIG_FILENAME =
'sources.yml'
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #direct? ⇒ Boolean
- #host ⇒ Object
-
#initialize(url) ⇒ Source
constructor
A new instance of Source.
- #search_engine? ⇒ Boolean
- #social_network? ⇒ Boolean
Constructor Details
#initialize(url) ⇒ Source
Returns a new instance of Source.
12 13 14 |
# File 'lib/channel_grouping/source.rb', line 12 def initialize(url) @url = url end |
Instance Attribute Details
#url ⇒ Object (readonly)
Returns the value of attribute url.
10 11 12 |
# File 'lib/channel_grouping/source.rb', line 10 def url @url end |
Class Method Details
.config ⇒ Object
44 45 46 47 |
# File 'lib/channel_grouping/source.rb', line 44 def self.config root = Pathname.new(File.("../../..", __FILE__)) YAML.load_file(root.join(CONFIG_FILENAME)) end |
.search_engines ⇒ Object
40 41 42 |
# File 'lib/channel_grouping/source.rb', line 40 def self.search_engines @search_engines ||= config['search_engines'] end |
.social_networks ⇒ Object
36 37 38 |
# File 'lib/channel_grouping/source.rb', line 36 def self. @social_networks ||= config['social_networks'] end |
Instance Method Details
#direct? ⇒ Boolean
28 29 30 |
# File 'lib/channel_grouping/source.rb', line 28 def direct? uri.host.nil? end |
#host ⇒ Object
32 33 34 |
# File 'lib/channel_grouping/source.rb', line 32 def host uri.host end |
#search_engine? ⇒ Boolean
16 17 18 19 20 |
# File 'lib/channel_grouping/source.rb', line 16 def search_engine? self.class.search_engines.any? do |search_engine_host| host_matches?(search_engine_host) end end |
#social_network? ⇒ Boolean
22 23 24 25 26 |
# File 'lib/channel_grouping/source.rb', line 22 def self.class..any? do || host_matches?() end end |