Class: Gzlib::Book

Inherits:
Object
  • Object
show all
Defined in:
lib/gzlib/book.rb

Constant Summary collapse

Search =
'http://opac.gzlib.gov.cn/opac/book/holdingpreview/'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node) ⇒ Book

Returns a new instance of Book.



10
11
12
13
14
15
16
17
# File 'lib/gzlib/book.rb', line 10

def initialize(node)
  @title = node.at_css('.bookmetaTitle').text.strip
  @id = node['bookrecno']
  metas = node.css('div')
  @author = metas[1].at_css('a').text.strip
  @publisher = metas[2].at_css('a').text.strip
  @year = metas[2].text.gsub(/[^\d]/,'')
end

Instance Attribute Details

#authorObject (readonly)

Returns the value of attribute author.



8
9
10
# File 'lib/gzlib/book.rb', line 8

def author
  @author
end

#idObject (readonly)

Returns the value of attribute id.



8
9
10
# File 'lib/gzlib/book.rb', line 8

def id
  @id
end

#publisherObject (readonly)

Returns the value of attribute publisher.



8
9
10
# File 'lib/gzlib/book.rb', line 8

def publisher
  @publisher
end

#titleObject (readonly)

Returns the value of attribute title.



8
9
10
# File 'lib/gzlib/book.rb', line 8

def title
  @title
end

#yearObject (readonly)

Returns the value of attribute year.



8
9
10
# File 'lib/gzlib/book.rb', line 8

def year
  @year
end

Instance Method Details

#positionsObject



19
20
21
# File 'lib/gzlib/book.rb', line 19

def positions
  @poss ||= Gzlib::Positions.new id
end