# frozen_string_literal: true
+require "util/inspector"
+
# Encapsulates information about an author
class Author
attr_accessor :grouping, :reading_order, :sort_order
end
def inspect
- field_info = [
- grouping.nil? ? nil : "grouping=\"#{grouping}\"",
- reading_order.nil? ? nil : "reading_order=\"#{reading_order}\"",
- sort_order.nil? ? nil : "sort_order=\"#{sort_order}\"",
- ].compact.join(" ")
-
- "(Author: #{field_info})"
+ Util::Inspector.inspect(self, %w[grouping reading_order sort_order])
end
def to_s
end
def inspect
- field_info = [
- author.nil? ? nil : "author=\"#{author.inspect}",
- series_id.nil? ? nil : "series_id=\"#{series_id.inspect}",
- volume.nil? ? nil : "volume=\"#{volume.inspect}",
- title.nil? ? nil : "title=\"#{title.inspect}",
- cover.nil? ? nil : "cover=\"#{cover.inspect}",
- path.nil? ? nil : "path=\"#{path.inspect}",
- ].compact.join(" ")
-
- "(Book: #{field_info})"
+ Inspector.inspect(self, %w[author series_id volume title cover path])
end
def to_s
# frozen_string_literal: true
+require "util/inspector"
+
# Encapsulates information about a book's classification, under the
# Dewey Decimal and/or Library of Congress systems.
class Classification
end
def inspect
- field_info = [
- ddc.nil? ? nil : "Dewey=#{ddc.inspect}",
- lcc.nil? ? nil : "LCC=#{lcc.inspect}",
- author_grouping.nil? ? nil : "author_grouping=#{author_grouping.inspect}",
- author.nil? ? nil : "author=#{author.inspect}",
- title_grouping.nil? ? nil : "title_grouping=#{title_grouping.inspect}",
- title.nil? ? nil : "title=#{title.inspect}",
- ].compact.join(", ")
-
- "(Classification: #{field_info})"
+ Util::Inspector.inspect(self, %w[ddc lcc author_grouping author title_grouping title])
end
def to_s
# frozen_string_literal: true
+require "util/inspector"
+
# Encapsulates data about a series of books
class Series
attr_reader :id
end
def inspect
- field_info = [
- age.nil? ? nil : "age=#{age.inspect}",
- code.nil? ? nil : "code=#{code.inspect}",
- descr.nil? ? nil : "descr=#{descr.inspect}",
- genre.nil? ? nil : "genre=#{genre.inspect}",
- grouping.nil? ? nil : "grouping=#{grouping.inspect}",
- ].compact.join(" ")
-
- "(Series: #{field_info})"
+ Util::Inspector.inspect(self, %w[age code descr genre grouping])
end
def key
classification = Classification.new(ddc, lcc, author_grouping, author_sort, title_grouping, title)
- expected = '(Classification: Dewey="973.3/092 B", LCC="E302.6.F7", author_grouping="BenjaminFranklin", ' \
- 'author="Franklin, Benjamin", title_grouping="Autobiography_of_Benjamin_Franklin", title="Autobiography ' \
+ expected = '(Classification: ddc="973.3/092 B" lcc="E302.6.F7" author_grouping="BenjaminFranklin" ' \
+ 'author="Franklin, Benjamin" title_grouping="Autobiography_of_Benjamin_Franklin" title="Autobiography ' \
'of Benjamin Franklin")'
actual = classification.inspect