Class: Sparkleology::LatestVersionCommand
- Inherits:
-
Object
- Object
- Sparkleology::LatestVersionCommand
- Defined in:
- lib/sparkleology/latest_version_command.rb
Instance Attribute Summary collapse
-
#rss_feed_url ⇒ Object
readonly
Returns the value of attribute rss_feed_url.
Instance Method Summary collapse
- #fetch_feed ⇒ Object
- #fetch_feed_in_temp_file ⇒ Object
-
#initialize(rss_feed_url) ⇒ LatestVersionCommand
constructor
A new instance of LatestVersionCommand.
- #run ⇒ Object
- #tmp_file_path ⇒ Object
Constructor Details
#initialize(rss_feed_url) ⇒ LatestVersionCommand
Returns a new instance of LatestVersionCommand.
4 5 6 |
# File 'lib/sparkleology/latest_version_command.rb', line 4 def initialize(rss_feed_url) @rss_feed_url = rss_feed_url end |
Instance Attribute Details
#rss_feed_url ⇒ Object (readonly)
Returns the value of attribute rss_feed_url.
2 3 4 |
# File 'lib/sparkleology/latest_version_command.rb', line 2 def rss_feed_url @rss_feed_url end |
Instance Method Details
#fetch_feed ⇒ Object
22 23 24 |
# File 'lib/sparkleology/latest_version_command.rb', line 22 def fetch_feed open(rss_feed_url).read end |
#fetch_feed_in_temp_file ⇒ Object
16 17 18 19 20 |
# File 'lib/sparkleology/latest_version_command.rb', line 16 def fetch_feed_in_temp_file File.open(tmp_file_path, "w+") do |file| file << self.fetch_feed end end |
#run ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/sparkleology/latest_version_command.rb', line 8 def run fetch_feed_in_temp_file feed_xml = XML::Document.file(tmp_file_path) node = feed_xml.find_first "//rss/channel/item" node = node.find_first "enclosure" node["url"] end |
#tmp_file_path ⇒ Object
26 27 28 |
# File 'lib/sparkleology/latest_version_command.rb', line 26 def tmp_file_path File.join(Dir::tmpdir, "sparkleology.rss") end |