Class: Reading::Row::SpansSubattribute
- Defined in:
- lib/reading/attribute/experiences/spans_subattribute.rb
Instance Method Summary collapse
-
#initialize(date_entry:, dates_finished:, date_index:, variant_index:, columns:, config:) ⇒ SpansSubattribute
constructor
A new instance of SpansSubattribute.
- #parse ⇒ Object
Constructor Details
#initialize(date_entry:, dates_finished:, date_index:, variant_index:, columns:, config:) ⇒ SpansSubattribute
Returns a new instance of SpansSubattribute.
14 15 16 17 18 19 20 21 |
# File 'lib/reading/attribute/experiences/spans_subattribute.rb', line 14 def initialize(date_entry:, dates_finished:, date_index:, variant_index:, columns:, config:) @date_entry = date_entry @dates_finished = dates_finished @date_index = date_index @variant_index = variant_index @columns = columns @config = config end |
Instance Method Details
#parse ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/reading/attribute/experiences/spans_subattribute.rb', line 23 def parse started = date_started(date_entry) finished = date_finished(dates_finished, date_index) return [] if started.nil? && finished.nil? progress_attr = ProgressSubattribute.new(date_entry:, variant_index:, columns:, config:) progress = progress_attr.parse [{ dates: started..finished || template.fetch(:dates), amount: length || template.fetch(:amount), progress: progress || (1.0 if finished) || template.fetch(:progress), name: template.fetch(:name), favorite?: template.fetch(:favorite?), }] end |