Class: NicoQuery::ObjectMapper::MylistRSS
- Inherits:
-
Object
- Object
- NicoQuery::ObjectMapper::MylistRSS
- Defined in:
- lib/nicoquery/object_mapper/mylist_rss.rb
Direct Known Subclasses
Defined Under Namespace
Instance Attribute Summary collapse
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#meta ⇒ Object
readonly
Returns the value of attribute meta.
Instance Method Summary collapse
-
#initialize(xml) ⇒ MylistRSS
constructor
A new instance of MylistRSS.
- #title_prefix ⇒ Object
Constructor Details
#initialize(xml) ⇒ MylistRSS
Returns a new instance of MylistRSS.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/nicoquery/object_mapper/mylist_rss.rb', line 8 def initialize(xml) parser = Nori.new parsed_xml = parser.parse xml entire = parsed_xml['rss']['channel'] = Meta.new entire, title_prefix # noriは子要素が複数の場合は配列に変換するが、1つの場合には配列にしない。 # しかし、MylistRSSはitemsが配列であること前提にしているので、item要素が # 1つだけの場合にも配列に変換する。 if entire['item'].is_a? Array @items = entire['item'].map { |item| Item.new item } else @items = [ Item.new(entire['item']) ] end end |
Instance Attribute Details
#items ⇒ Object (readonly)
Returns the value of attribute items.
7 8 9 |
# File 'lib/nicoquery/object_mapper/mylist_rss.rb', line 7 def items @items end |
#meta ⇒ Object (readonly)
Returns the value of attribute meta.
7 8 9 |
# File 'lib/nicoquery/object_mapper/mylist_rss.rb', line 7 def end |
Instance Method Details
#title_prefix ⇒ Object
23 24 25 |
# File 'lib/nicoquery/object_mapper/mylist_rss.rb', line 23 def title_prefix "マイリスト" end |