Sha256: 119d7e34afbbd0199d4b60ab438da992b23993132b9ac851336c4672b82926f0
Contents?: true
Size: 1.64 KB
Versions: 2
Compression:
Stored size: 1.64 KB
Contents
# encoding: utf-8 module ARBookFinder class Book attr_reader :cover, :title, :author, :summary, :ar_quiz_number, :language, :ar_quiz_availability, :atos_book_level, :interest_level, :ar_points, :rating, :word_count, :type, :topics, :series, :url, :publishers def initialize(url) @url = url @publishers = [] end def fetch BookDetailProcessor.new(@url).process load(BookDetailParser.new(Capybara.page.html).parse) self end private def load(parsed_data) parsed_data.keys.each do |k| instance_variable_set("@#{k}", parsed_data[k]) unless [:ar_quiz_availability, :topics, :series, :publishers].include?(k) end load_ar_quiz_availability(parsed_data[:ar_quiz_availability]) load_topics(parsed_data[:topics]) load_series(parsed_data[:series]) load_publishers(parsed_data[:publishers]) end def load_ar_quiz_availability(ar_quiz_availability) @ar_quiz_availability = ar_quiz_availability.split(',').collect { |v| v.strip.gsub(' ', '') } end def load_topics(topics) @topics = topics.split(';').collect do |topic| topic.split('-').collect { |v| v.strip } end end def load_series(series) @series = series.split(';').collect { |v| v.strip } end def load_publishers(publishers) publishers.each { |p| @publishers << Publisher.new(p) } end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ar_book_finder-1.1.1 | lib/ar_book_finder/book.rb |
ar_book_finder-1.1.0 | lib/ar_book_finder/book.rb |