Class: UqLibraries::Library
- Inherits:
-
Object
- Object
- UqLibraries::Library
- Defined in:
- lib/uq_libraries/library.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#details ⇒ Object
Returns the value of attribute details.
-
#library_url ⇒ Object
Returns the value of attribute library_url.
-
#name ⇒ Object
Returns the value of attribute name.
-
#total_available ⇒ Object
Returns the value of attribute total_available.
-
#total_out_of_available ⇒ Object
Returns the value of attribute total_out_of_available.
Class Method Summary collapse
-
.all ⇒ Object
Getter method for @@all array.
-
.create_from_collection(libraries_array) ⇒ Object
Creates library instance from an array of hashes returned by Scraper#scrape_main_page.
Instance Method Summary collapse
-
#add_details ⇒ Object
Sets library.details equal to an array of hashes containing different details for each level of the library.
-
#initialize(library_hash) ⇒ Library
constructor
A new instance of Library.
Constructor Details
#initialize(library_hash) ⇒ Library
Returns a new instance of Library.
5 6 7 8 9 |
# File 'lib/uq_libraries/library.rb', line 5 def initialize(library_hash) library_hash.each {|attribute, value| self.send("#{attribute}=", value)} add_details @@all << self end |
Instance Attribute Details
#details ⇒ Object
Returns the value of attribute details.
2 3 4 |
# File 'lib/uq_libraries/library.rb', line 2 def details @details end |
#library_url ⇒ Object
Returns the value of attribute library_url.
2 3 4 |
# File 'lib/uq_libraries/library.rb', line 2 def library_url @library_url end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/uq_libraries/library.rb', line 2 def name @name end |
#total_available ⇒ Object
Returns the value of attribute total_available.
2 3 4 |
# File 'lib/uq_libraries/library.rb', line 2 def total_available @total_available end |
#total_out_of_available ⇒ Object
Returns the value of attribute total_out_of_available.
2 3 4 |
# File 'lib/uq_libraries/library.rb', line 2 def total_out_of_available @total_out_of_available end |
Class Method Details
.all ⇒ Object
Getter method for @@all array. Returns all Library instances
15 16 17 |
# File 'lib/uq_libraries/library.rb', line 15 def self.all # Getter method for @@all array. Returns all Library instances @@all end |
.create_from_collection(libraries_array) ⇒ Object
Creates library instance from an array of hashes returned by Scraper#scrape_main_page
11 12 13 |
# File 'lib/uq_libraries/library.rb', line 11 def self.create_from_collection(libraries_array) # Creates library instance from an array of hashes returned by Scraper#scrape_main_page libraries_array.each {|i| self.new(i)} end |
Instance Method Details
#add_details ⇒ Object
Sets library.details equal to an array of hashes containing different details for each level of the library
19 20 21 |
# File 'lib/uq_libraries/library.rb', line 19 def add_details # Sets library.details equal to an array of hashes containing different details for each level of the library @details = UqLibraries::LibraryDetails.create_from_collection(UqLibraries::Scraper.scrape_details_page(@library_url)) end |