Class: Html2rss::Config
- Inherits:
-
Object
- Object
- Html2rss::Config
- Defined in:
- lib/html2rss/config.rb
Instance Method Summary collapse
- #attribute_names ⇒ Object
- #author ⇒ Object
- #categories ⇒ Object
- #description ⇒ Object
- #headers ⇒ Object
-
#initialize(feed_config, global_config = {}) ⇒ Config
constructor
A new instance of Config.
- #language ⇒ Object
- #options(name) ⇒ Object
- #selector(name) ⇒ Object
- #title ⇒ Object
- #ttl ⇒ Object
- #url ⇒ Object (also: #link)
Constructor Details
#initialize(feed_config, global_config = {}) ⇒ Config
Returns a new instance of Config
3 4 5 6 7 |
# File 'lib/html2rss/config.rb', line 3 def initialize(feed_config, global_config = {}) @global_config = Utils::IndifferentAccessHash.new global_config @feed_config = Utils::IndifferentAccessHash.new feed_config @channel_config = Utils::IndifferentAccessHash.new @feed_config.fetch('channel', {}) end |
Instance Method Details
#attribute_names ⇒ Object
50 51 52 53 54 |
# File 'lib/html2rss/config.rb', line 50 def attribute_names attribute_names = feed_config.fetch('selectors', {}).keys.map(&:to_s) attribute_names.delete('items') attribute_names end |
#author ⇒ Object
9 10 11 |
# File 'lib/html2rss/config.rb', line 9 def channel_config.fetch 'author', 'html2rss' end |
#categories ⇒ Object
42 43 44 |
# File 'lib/html2rss/config.rb', line 42 def categories feed_config.dig('selectors').fetch('categories', []) end |
#description ⇒ Object
25 26 27 |
# File 'lib/html2rss/config.rb', line 25 def description channel_config.fetch 'description', 'A description of my html2rss feed.' end |
#headers ⇒ Object
34 35 36 |
# File 'lib/html2rss/config.rb', line 34 def headers global_config.fetch('headers', {}) end |
#language ⇒ Object
21 22 23 |
# File 'lib/html2rss/config.rb', line 21 def language channel_config.fetch 'language', 'en' end |
#options(name) ⇒ Object
38 39 40 |
# File 'lib/html2rss/config.rb', line 38 def (name) feed_config.dig('selectors').fetch(name, {}).merge('channel' => channel_config) end |
#selector(name) ⇒ Object
46 47 48 |
# File 'lib/html2rss/config.rb', line 46 def selector(name) feed_config.dig('selectors', name, 'selector') end |
#title ⇒ Object
17 18 19 |
# File 'lib/html2rss/config.rb', line 17 def title channel_config.fetch 'title', 'html2rss generated title' end |
#ttl ⇒ Object
13 14 15 |
# File 'lib/html2rss/config.rb', line 13 def ttl channel_config.fetch 'ttl', 3600 end |
#url ⇒ Object Also known as: link
29 30 31 |
# File 'lib/html2rss/config.rb', line 29 def url channel_config.dig 'url' end |