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
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.
44 45 46 47 48 49 50 51 |
# File 'lib/html2rss/config.rb', line 44 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.
79 80 81 |
# File 'lib/html2rss/config.rb', line 79 def channel @channel end |
Instance Method Details
#headers ⇒ Hash
Retrieves headers merged from global settings and channel headers.
66 67 68 |
# File 'lib/html2rss/config.rb', line 66 def headers @global.fetch(:headers, {}).merge(@channel.headers) end |
#selector_attributes_with_channel(name) ⇒ Hash<Symbol, Object>
Retrieves selector attributes merged with channel attributes.
58 59 60 |
# File 'lib/html2rss/config.rb', line 58 def selector_attributes_with_channel(name) @selectors.selector(name).to_h.merge(channel: @channel) end |
#stylesheets ⇒ Array<Stylesheet>
Retrieves stylesheets from global settings.
74 75 76 |
# File 'lib/html2rss/config.rb', line 74 def stylesheets @global.fetch(:stylesheets, []).map { |attributes| Html2rss::RssBuilder::Stylesheet.new(**attributes) } end |