Class: Elibrum::Book
- Inherits:
-
Object
- Object
- Elibrum::Book
- Defined in:
- lib/elibrum/book.rb
Instance Attribute Summary collapse
-
#author ⇒ Object
Returns the value of attribute author.
-
#pages ⇒ Object
readonly
Returns the value of attribute pages.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
- #add(*links, &block) ⇒ Object
-
#initialize(filename, &block) ⇒ Book
constructor
A new instance of Book.
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
#author ⇒ Object
Returns the value of attribute author.
3 4 5 |
# File 'lib/elibrum/book.rb', line 3 def @author end |
#pages ⇒ Object (readonly)
Returns the value of attribute pages.
4 5 6 |
# File 'lib/elibrum/book.rb', line 4 def pages @pages end |
#title ⇒ Object
Returns the value of attribute title.
3 4 5 |
# File 'lib/elibrum/book.rb', line 3 def title @title end |