Class: Elibrum::Book

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename, &block) ⇒ Book

Returns a new instance of Book.



6
7
8
9
10
11
12
# File 'lib/elibrum/book.rb', line 6

def initialize(filename, &block)
	@title = filename.split(/_|-/).map(&:capitalize).join(" ")
	@author = "Unknown"
	@pages = []

	block.arity < 1 ? instance_eval(&block) : block.call(self)
end

Instance Attribute Details

#authorObject

Returns the value of attribute author.



3
4
5
# File 'lib/elibrum/book.rb', line 3

def author
  @author
end

#pagesObject (readonly)

Returns the value of attribute pages.



4
5
6
# File 'lib/elibrum/book.rb', line 4

def pages
  @pages
end

#titleObject

Returns the value of attribute title.



3
4
5
# File 'lib/elibrum/book.rb', line 3

def title
  @title
end

Instance Method Details

#add(*links, &block) ⇒ Object



14
15
16
17
18
# File 'lib/elibrum/book.rb', line 14

def add(*links, &block)
	links.each do |url|
		@pages << Webpage.new(url, &block)
	end
end