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.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/nicoquery/object_mapper/mylist_rss.rb', line 9 def initialize(xml) @parser = Nori.new @parsed_xml = @parser.parse xml entire = @parsed_xml['rss']['channel'] @meta = Meta.new entire, title_prefix if entire['item'].is_a? Array @items = entire['item'].map { |item| Item.new item } elsif entire['item'].nil? @items = [] else # noriは子要素が複数の場合は配列に変換するが、1つの場合には配列にしない。 # しかし、MylistRSSはitemsが配列であること前提にしているので、item要素が # 1つだけの場合にも配列に変換する必要がある。 @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 @meta end |
Instance Method Details
#title_prefix ⇒ Object
27 28 29 |
# File 'lib/nicoquery/object_mapper/mylist_rss.rb', line 27 def title_prefix "マイリスト" end |