Class: RssFeed::Feed::Base
Overview
The Base class serves as the base class for all feed parsers.
Instance Attribute Summary collapse
-
#document ⇒ Object
readonly
Returns the value of attribute document.
Instance Method Summary collapse
-
#detect_feed_type ⇒ String
Detects the type of the feed based on the root element of the XML document.
-
#execute_method ⇒ Object
Executes the appropriate parsing method based on the detected feed type.
-
#initialize(document) ⇒ Base
constructor
Initializes a new Base instance.
-
#parser ⇒ Object
abstract
This method should be implemented by subclasses to define the specific parsing logic.
Constructor Details
#initialize(document) ⇒ Base
Initializes a new Base instance.
10 11 12 |
# File 'lib/rss_feed/feed/base.rb', line 10 def initialize(document) @document = document end |
Instance Attribute Details
#document ⇒ Object (readonly)
Returns the value of attribute document.
5 6 7 |
# File 'lib/rss_feed/feed/base.rb', line 5 def document @document end |
Instance Method Details
#detect_feed_type ⇒ String
Detects the type of the feed based on the root element of the XML document.
24 25 26 |
# File 'lib/rss_feed/feed/base.rb', line 24 def detect_feed_type document.root.name end |
#execute_method ⇒ Object
Executes the appropriate parsing method based on the detected feed type.
31 32 33 34 35 36 |
# File 'lib/rss_feed/feed/base.rb', line 31 def execute_method method_name = detect_feed_type raise NotImplementedError unless respond_to?(method_name) send(method_name) end |
#parser ⇒ Object
This method is abstract.
This method should be implemented by subclasses to define the specific parsing logic.
17 18 19 |
# File 'lib/rss_feed/feed/base.rb', line 17 def parser raise NotImplementedError end |