Class: Reading::Item::View
Overview
A view object for an Item, providing shortcuts to information that is handy to show (for example) on a webpage.
Instance Attribute Summary collapse
-
#blurb ⇒ Object
readonly
Returns the value of attribute blurb.
-
#date_or_status ⇒ Object
readonly
Returns the value of attribute date_or_status.
-
#experience_count ⇒ Object
readonly
Returns the value of attribute experience_count.
-
#genres ⇒ Object
readonly
Returns the value of attribute genres.
-
#groups ⇒ Object
readonly
Returns the value of attribute groups.
-
#isbn ⇒ Object
readonly
Returns the value of attribute isbn.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#public_notes ⇒ Object
readonly
Returns the value of attribute public_notes.
-
#rating ⇒ Object
readonly
Returns the value of attribute rating.
-
#type_emoji ⇒ Object
readonly
Returns the value of attribute type_emoji.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(item) ⇒ View
constructor
A new instance of View.
Constructor Details
#initialize(item) ⇒ View
Returns a new instance of View.
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/reading/item/view.rb', line 12 def initialize(item) @genres = item.genres @rating = (item) @isbn, @url, variant = extract_first_source_info(item) @name = extract_name(item, variant) @type_emoji = extract_type_emoji(variant&.format) @date_or_status = extract_date_or_status(item) @experience_count = item.experiences.count @groups = item.experiences.map(&:group).compact @blurb = item.notes.find(&:blurb?)&.content @public_notes = item.notes.reject(&:private?).reject(&:blurb?).map(&:content) end |
Instance Attribute Details
#blurb ⇒ Object (readonly)
Returns the value of attribute blurb.
8 9 10 |
# File 'lib/reading/item/view.rb', line 8 def blurb @blurb end |
#date_or_status ⇒ Object (readonly)
Returns the value of attribute date_or_status.
8 9 10 |
# File 'lib/reading/item/view.rb', line 8 def date_or_status @date_or_status end |
#experience_count ⇒ Object (readonly)
Returns the value of attribute experience_count.
8 9 10 |
# File 'lib/reading/item/view.rb', line 8 def experience_count @experience_count end |
#genres ⇒ Object (readonly)
Returns the value of attribute genres.
8 9 10 |
# File 'lib/reading/item/view.rb', line 8 def genres @genres end |
#groups ⇒ Object (readonly)
Returns the value of attribute groups.
8 9 10 |
# File 'lib/reading/item/view.rb', line 8 def groups @groups end |
#isbn ⇒ Object (readonly)
Returns the value of attribute isbn.
8 9 10 |
# File 'lib/reading/item/view.rb', line 8 def isbn @isbn end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/reading/item/view.rb', line 8 def name @name end |
#public_notes ⇒ Object (readonly)
Returns the value of attribute public_notes.
8 9 10 |
# File 'lib/reading/item/view.rb', line 8 def public_notes @public_notes end |
#rating ⇒ Object (readonly)
Returns the value of attribute rating.
8 9 10 |
# File 'lib/reading/item/view.rb', line 8 def @rating end |
#type_emoji ⇒ Object (readonly)
Returns the value of attribute type_emoji.
8 9 10 |
# File 'lib/reading/item/view.rb', line 8 def type_emoji @type_emoji end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
8 9 10 |
# File 'lib/reading/item/view.rb', line 8 def url @url end |