Class: Mako::SubscriptionListParser
- Inherits:
-
Object
- Object
- Mako::SubscriptionListParser
- Includes:
- FileOpenUtil
- Defined in:
- lib/mako/subscription_list_parser.rb
Instance Attribute Summary collapse
-
#list ⇒ Object
readonly
Returns the value of attribute list.
Instance Method Summary collapse
-
#initialize(args) ⇒ SubscriptionListParser
constructor
A new instance of SubscriptionListParser.
-
#load_list ⇒ String
Load the subscription list file.
-
#parse ⇒ Array
Parses OPML, JSON, or plain text documents and returns an Array of feed urls.
Methods included from FileOpenUtil
Constructor Details
#initialize(args) ⇒ SubscriptionListParser
Returns a new instance of SubscriptionListParser.
9 10 11 |
# File 'lib/mako/subscription_list_parser.rb', line 9 def initialize(args) @list = args.fetch(:list) end |
Instance Attribute Details
#list ⇒ Object (readonly)
Returns the value of attribute list.
7 8 9 |
# File 'lib/mako/subscription_list_parser.rb', line 7 def list @list end |
Instance Method Details
#load_list ⇒ String
Load the subscription list file
30 31 32 |
# File 'lib/mako/subscription_list_parser.rb', line 30 def load_list load_resource(list) end |
#parse ⇒ Array
Parses OPML, JSON, or plain text documents and returns an Array of feed urls.
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/mako/subscription_list_parser.rb', line 16 def parse case File.extname list when '.xml' || '.opml' Nokogiri::XML(load_list).xpath('//@xmlUrl').map(&:value) when '.json' JSON.parse(load_list) when '.txt' load_list.split("\n") end end |