Class: Alx::Book
- Inherits:
-
Object
- Object
- Alx::Book
- Defined in:
- lib/alx/book.rb
Instance Attribute Summary collapse
-
#file_name ⇒ Object
readonly
Returns the value of attribute file_name.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #content ⇒ Object
-
#initialize(title, file_name) ⇒ Book
constructor
A new instance of Book.
Constructor Details
#initialize(title, file_name) ⇒ Book
Returns a new instance of Book.
5 6 7 8 |
# File 'lib/alx/book.rb', line 5 def initialize( title, file_name ) @title = title @file_name = file_name end |
Instance Attribute Details
#file_name ⇒ Object (readonly)
Returns the value of attribute file_name.
4 5 6 |
# File 'lib/alx/book.rb', line 4 def file_name @file_name end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
4 5 6 |
# File 'lib/alx/book.rb', line 4 def title @title end |
Instance Method Details
#content ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/alx/book.rb', line 10 def content content = "" File.open( @file_name ) do | file | file.each { | line | content+=line } end return content end |