Class: FeedElementInstaller
- Inherits:
-
Object
- Object
- FeedElementInstaller
- Defined in:
- lib/feed_element_installer.rb
Instance Attribute Summary collapse
-
#element_accessor ⇒ Object
readonly
Returns the value of attribute element_accessor.
-
#element_name ⇒ Object
readonly
Returns the value of attribute element_name.
-
#element_namespace ⇒ Object
readonly
Returns the value of attribute element_namespace.
-
#feed ⇒ Object
readonly
Returns the value of attribute feed.
-
#original_name ⇒ Object
readonly
Returns the value of attribute original_name.
Class Method Summary collapse
Instance Method Summary collapse
- #element_uri ⇒ Object
-
#initialize(element_name, feed) ⇒ FeedElementInstaller
constructor
A new instance of FeedElementInstaller.
- #install ⇒ Object
Constructor Details
#initialize(element_name, feed) ⇒ FeedElementInstaller
Returns a new instance of FeedElementInstaller.
18 19 20 21 22 23 |
# File 'lib/feed_element_installer.rb', line 18 def initialize(element_name, feed) @feed = feed @original_name = element_name @element_namespace, @element_name = *element_name.split(":") @element_accessor = "#{@element_namespace}_#{@element_name}" end |
Instance Attribute Details
#element_accessor ⇒ Object (readonly)
Returns the value of attribute element_accessor.
16 17 18 |
# File 'lib/feed_element_installer.rb', line 16 def element_accessor @element_accessor end |
#element_name ⇒ Object (readonly)
Returns the value of attribute element_name.
16 17 18 |
# File 'lib/feed_element_installer.rb', line 16 def element_name @element_name end |
#element_namespace ⇒ Object (readonly)
Returns the value of attribute element_namespace.
16 17 18 |
# File 'lib/feed_element_installer.rb', line 16 def element_namespace @element_namespace end |
#feed ⇒ Object (readonly)
Returns the value of attribute feed.
16 17 18 |
# File 'lib/feed_element_installer.rb', line 16 def feed @feed end |
#original_name ⇒ Object (readonly)
Returns the value of attribute original_name.
16 17 18 |
# File 'lib/feed_element_installer.rb', line 16 def original_name @original_name end |
Class Method Details
.install(element_name, feed) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/feed_element_installer.rb', line 9 def self.install(element_name, feed) # RSS Specification at http://cyber.harvard.edu/rss/rss.html#extendingRss # > A RSS feed may contain [non-standard elements], only if those elements are *defined in a namespace* new(element_name, feed).install if element_name.include?(":") end |
Instance Method Details
#element_uri ⇒ Object
25 26 27 28 |
# File 'lib/feed_element_installer.rb', line 25 def element_uri @element_uri ||= REXML::Document.new(feed).root&.attributes&.namespaces&.fetch(@element_namespace, "") || "" end |
#install ⇒ Object
30 31 32 33 |
# File 'lib/feed_element_installer.rb', line 30 def install install_in_rss unless installed_in_rss? install_in_atom unless installed_in_atom? end |