Class: Html2rss::Config
- Inherits:
-
Object
- Object
- Html2rss::Config
- Defined in:
- lib/html2rss/config.rb
Instance Attribute Summary collapse
-
#channel_config ⇒ Object
readonly
Returns the value of attribute channel_config.
-
#feed_config ⇒ Object
readonly
Returns the value of attribute feed_config.
Instance Method Summary collapse
- #attribute_names ⇒ Object
- #author ⇒ Object
- #categories ⇒ Object
- #description ⇒ Object
- #headers ⇒ Object
-
#initialize(config, name) ⇒ 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(config, name) ⇒ Config
Returns a new instance of Config.
5 6 7 8 9 |
# File 'lib/html2rss/config.rb', line 5 def initialize(config, name) @config = config @feed_config = @config['feeds'][name.to_s] @channel_config = @feed_config['channel'] end |
Instance Attribute Details
#channel_config ⇒ Object (readonly)
Returns the value of attribute channel_config.
3 4 5 |
# File 'lib/html2rss/config.rb', line 3 def channel_config @channel_config end |
#feed_config ⇒ Object (readonly)
Returns the value of attribute feed_config.
3 4 5 |
# File 'lib/html2rss/config.rb', line 3 def feed_config @feed_config end |
Instance Method Details
#attribute_names ⇒ Object
52 53 54 55 56 |
# File 'lib/html2rss/config.rb', line 52 def attribute_names attribute_names = feed_config.fetch('selectors', {}).keys.map(&:to_s) attribute_names.delete('items') attribute_names end |
#author ⇒ Object
11 12 13 |
# File 'lib/html2rss/config.rb', line 11 def channel_config.fetch 'author', 'html2rss' end |
#categories ⇒ Object
44 45 46 |
# File 'lib/html2rss/config.rb', line 44 def categories feed_config.dig('selectors').fetch('categories', []) end |
#description ⇒ Object
27 28 29 |
# File 'lib/html2rss/config.rb', line 27 def description channel_config.fetch 'description', 'A description of my html2rss feed.' end |
#headers ⇒ Object
36 37 38 |
# File 'lib/html2rss/config.rb', line 36 def headers @config.fetch('headers', {}) end |
#language ⇒ Object
23 24 25 |
# File 'lib/html2rss/config.rb', line 23 def language channel_config.fetch 'language', 'en' end |
#options(name) ⇒ Object
40 41 42 |
# File 'lib/html2rss/config.rb', line 40 def (name) feed_config.dig('selectors').fetch(name, {}).merge('channel' => channel_config) end |
#selector(name) ⇒ Object
48 49 50 |
# File 'lib/html2rss/config.rb', line 48 def selector(name) feed_config.dig('selectors', name, 'selector') end |
#title ⇒ Object
19 20 21 |
# File 'lib/html2rss/config.rb', line 19 def title channel_config.fetch 'title', 'html2rss generated title' end |
#ttl ⇒ Object
15 16 17 |
# File 'lib/html2rss/config.rb', line 15 def ttl (channel_config.fetch 'ttl').to_i || nil end |
#url ⇒ Object Also known as: link
31 32 33 |
# File 'lib/html2rss/config.rb', line 31 def url channel_config.dig 'url' end |