Class: Niconico::Mylist

Inherits:
Object
  • Object
show all
Includes:
Xpathable
Defined in:
lib/niconico/mylist.rb,
lib/niconico/mylist/item.rb,
lib/niconico/mylist/error.rb,
lib/niconico/mylist/client.rb,
lib/niconico/mylist/config.rb,
lib/niconico/mylist/version.rb,
lib/niconico/mylist/xpathable.rb

Defined Under Namespace

Modules: Xpathable Classes: Client, Config, Error, Item

Constant Summary collapse

ENDPOINT =
'http://www.nicovideo.jp'
VERSION =
'0.2.1'

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Mylist

Returns a new instance of Mylist.


43
44
45
# File 'lib/niconico/mylist.rb', line 43

def initialize(data)
  @data = data
end

Class Method Details

.configObject


20
21
22
# File 'lib/niconico/mylist.rb', line 20

def config
  @config ||= Niconico::Mylist::Config.new
end

.configure {|config| ... } ⇒ Object

Yields:


24
25
26
# File 'lib/niconico/mylist.rb', line 24

def configure
  yield(config) if block_given?
end

.find(id) ⇒ Object


28
29
30
# File 'lib/niconico/mylist.rb', line 28

def find(id)
  new(client.find_xml(id))
end

Instance Method Details

#creatorObject


67
68
69
# File 'lib/niconico/mylist.rb', line 67

def creator
  @creator ||= xpath_text('channel/dc:creator')
end

#descriptionObject


55
56
57
# File 'lib/niconico/mylist.rb', line 55

def description
  @description ||= xpath_text('channel/description')
end

#inspectObject


75
76
77
# File 'lib/niconico/mylist.rb', line 75

def inspect
  "#<#{self.class.name} title: #{title} creator: #{creator}>"
end

#itemsObject


71
72
73
# File 'lib/niconico/mylist.rb', line 71

def items
  @items ||= xpath_match('channel/item').map { |item| Niconico::Mylist::Item.new(item) }
end

#last_build_dateObject


63
64
65
# File 'lib/niconico/mylist.rb', line 63

def last_build_date
  @last_build_date ||= Time.parse(xpath_text('channel/lastBuildDate'))
end

51
52
53
# File 'lib/niconico/mylist.rb', line 51

def link
  @link ||= xpath_text('channel/link')
end

#pub_dateObject


59
60
61
# File 'lib/niconico/mylist.rb', line 59

def pub_date
  @pub_date ||= Time.parse(xpath_text('channel/pubDate'))
end

#titleObject


47
48
49
# File 'lib/niconico/mylist.rb', line 47

def title
  @title ||= xpath_text('channel/title').match(%r{マイリスト (.+?)‐ニコニコ動画})[1]
end