Class: Alx::Book

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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_nameObject (readonly)

Returns the value of attribute file_name.



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

def file_name
  @file_name
end

#titleObject (readonly)

Returns the value of attribute title.



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

def title
  @title
end

Instance Method Details

#contentObject



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