Class: Html2rss::Config
- Inherits:
-
Object
- Object
- Html2rss::Config
- Extended by:
- Forwardable
- Defined in:
- lib/html2rss/config.rb,
lib/html2rss/config/channel.rb,
lib/html2rss/config/selectors.rb
Overview
The Config class abstracts from the config data structure and provides default values.
Defined Under Namespace
Classes: Channel, ChannelMissing, ParamsMissing, Selectors, Stylesheet
Instance Attribute Summary collapse
-
#channel ⇒ Object
readonly
Provides read-only access to the channel object.
Instance Method Summary collapse
-
#headers ⇒ Hash
Retrieves headers merged from global settings and channel headers.
-
#initialize(feed_config, global = {}, params = {}) ⇒ Config
constructor
Initializes the Config object with feed configuration, global settings, and parameters.
-
#selector_attributes_with_channel(name) ⇒ Hash<Symbol, Object>
Retrieves selector attributes merged with channel attributes.
-
#stylesheets ⇒ Array<Stylesheet>
Retrieves stylesheets from global settings.
Constructor Details
#initialize(feed_config, global = {}, params = {}) ⇒ Config
Initializes the Config object with feed configuration, global settings, and parameters.
47 48 49 50 51 52 53 54 |
# File 'lib/html2rss/config.rb', line 47 def initialize(feed_config, global = {}, params = {}) channel_config = feed_config[:channel] raise ChannelMissing, 'Channel configuration is missing in feed_config' unless channel_config @channel = Channel.new(channel_config, params:) @selectors = Selectors.new(feed_config[:selectors]) @global = global end |
Instance Attribute Details
#channel ⇒ Object (readonly)
Provides read-only access to the channel object.
82 83 84 |
# File 'lib/html2rss/config.rb', line 82 def channel @channel end |
Instance Method Details
#headers ⇒ Hash
Retrieves headers merged from global settings and channel headers.
69 70 71 |
# File 'lib/html2rss/config.rb', line 69 def headers @global.fetch(:headers, {}).merge(@channel.headers) end |
#selector_attributes_with_channel(name) ⇒ Hash<Symbol, Object>
Retrieves selector attributes merged with channel attributes.
61 62 63 |
# File 'lib/html2rss/config.rb', line 61 def selector_attributes_with_channel(name) @selectors.selector(name).to_h.merge(channel: @channel) end |
#stylesheets ⇒ Array<Stylesheet>
Retrieves stylesheets from global settings.
77 78 79 |
# File 'lib/html2rss/config.rb', line 77 def stylesheets @global.fetch(:stylesheets, []).map { |attributes| Stylesheet.new(attributes) } end |