Class: Kindai::Spread

Inherits:
Object
  • Object
show all
Defined in:
lib/kindai/spread.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bookObject

Returns the value of attribute book.



4
5
6
# File 'lib/kindai/spread.rb', line 4

def book
  @book
end

#spread_numberObject

Returns the value of attribute spread_number.



5
6
7
# File 'lib/kindai/spread.rb', line 5

def spread_number
  @spread_number
end

Class Method Details

.new_from_book_and_spread_number(book, spread_number) ⇒ Object

Raises:

  • (TypeError)


7
8
9
10
11
12
13
# File 'lib/kindai/spread.rb', line 7

def self.new_from_book_and_spread_number(book, spread_number)
  raise TypeError, "#{book} is not Kindai::Book" unless book.is_a? Kindai::Book
  me = new
  me.book = book
  me.spread_number = spread_number
  me
end

Instance Method Details

#image_uriObject



19
20
21
22
23
24
25
26
# File 'lib/kindai/spread.rb', line 19

def image_uri
  params = {
    :itemId => "info:ndljp/pid/#{book.key}",
    :contentNo => spread_number,
    :outputScale => 1,
  }
  "http://kindai.ndl.go.jp/view/jpegOutput?" + Kindai::Util.expand_params(params)
end

#pageObject

protected XXX: book use this



30
31
32
# File 'lib/kindai/spread.rb', line 30

def page
  @page ||= Nokogiri Kindai::Util.fetch_uri self.uri
end

#uriObject



15
16
17
# File 'lib/kindai/spread.rb', line 15

def uri
  "#{book.permalink_uri}/#{spread_number.to_s}"
end