anki_record 0.2.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/.rubocop.yml +13 -2
 - data/CHANGELOG.md +37 -9
 - data/Gemfile +3 -1
 - data/Gemfile.lock +10 -2
 - data/README.md +120 -35
 - data/anki_record.gemspec +1 -5
 - data/lib/anki_record/anki_package/anki_package.rb +237 -0
 - data/lib/anki_record/card/card.rb +108 -0
 - data/lib/anki_record/card/card_attributes.rb +39 -0
 - data/lib/anki_record/card_template/card_template.rb +64 -0
 - data/lib/anki_record/card_template/card_template_attributes.rb +69 -0
 - data/lib/anki_record/collection/collection.rb +182 -0
 - data/lib/anki_record/collection/collection_attributes.rb +35 -0
 - data/lib/anki_record/database_setup_constants.rb +88 -0
 - data/lib/anki_record/deck/deck.rb +99 -0
 - data/lib/anki_record/deck/deck_attributes.rb +30 -0
 - data/lib/anki_record/deck/deck_defaults.rb +19 -0
 - data/lib/anki_record/{deck_options_group.rb → deck_options_group/deck_options_group.rb} +12 -31
 - data/lib/anki_record/deck_options_group/deck_options_group_attributes.rb +23 -0
 - data/lib/anki_record/helpers/checksum_helper.rb +10 -11
 - data/lib/anki_record/helpers/data_query_helper.rb +15 -0
 - data/lib/anki_record/helpers/shared_constants_helper.rb +6 -6
 - data/lib/anki_record/helpers/time_helper.rb +18 -13
 - data/lib/anki_record/note/note.rb +178 -0
 - data/lib/anki_record/note/note_attributes.rb +56 -0
 - data/lib/anki_record/note_field/note_field.rb +62 -0
 - data/lib/anki_record/note_field/note_field_attributes.rb +39 -0
 - data/lib/anki_record/note_field/note_field_defaults.rb +19 -0
 - data/lib/anki_record/note_type/note_type.rb +161 -0
 - data/lib/anki_record/note_type/note_type_attributes.rb +80 -0
 - data/lib/anki_record/note_type/note_type_defaults.rb +38 -0
 - data/lib/anki_record/version.rb +1 -1
 - data/lib/anki_record.rb +1 -16
 - metadata +26 -16
 - data/lib/anki_record/anki_package.rb +0 -194
 - data/lib/anki_record/card.rb +0 -75
 - data/lib/anki_record/card_template.rb +0 -105
 - data/lib/anki_record/collection.rb +0 -105
 - data/lib/anki_record/db/anki_schema_definition.rb +0 -77
 - data/lib/anki_record/db/clean_collection21_record.rb +0 -10
 - data/lib/anki_record/db/clean_collection2_record.rb +0 -10
 - data/lib/anki_record/deck.rb +0 -101
 - data/lib/anki_record/note.rb +0 -135
 - data/lib/anki_record/note_field.rb +0 -84
 - data/lib/anki_record/note_type.rb +0 -233
 
| 
         @@ -1,84 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # frozen_string_literal: true
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            # TODO: raise exceptions on invalid assignment to prevent downstream errors and specs for the writeable attributes
         
     | 
| 
       4 
     | 
    
         
            -
            # TODO: All instance variables should at least be readable
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
            require "pry"
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
            module AnkiRecord
         
     | 
| 
       9 
     | 
    
         
            -
              ##
         
     | 
| 
       10 
     | 
    
         
            -
              # NoteField represents a field of an Anki note type
         
     | 
| 
       11 
     | 
    
         
            -
              class NoteField
         
     | 
| 
       12 
     | 
    
         
            -
                DEFAULT_FIELD_FONT_STYLE = "Arial"
         
     | 
| 
       13 
     | 
    
         
            -
                DEFAULT_FIELD_FONT_SIZE = 20
         
     | 
| 
       14 
     | 
    
         
            -
                DEFAULT_FIELD_DESCRIPTION = ""
         
     | 
| 
       15 
     | 
    
         
            -
                private_constant :DEFAULT_FIELD_FONT_STYLE, :DEFAULT_FIELD_FONT_SIZE, :DEFAULT_FIELD_DESCRIPTION
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
                ##
         
     | 
| 
       18 
     | 
    
         
            -
                # The note type that the note field belongs to
         
     | 
| 
       19 
     | 
    
         
            -
                attr_reader :note_type
         
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
                ##
         
     | 
| 
       22 
     | 
    
         
            -
                # The name of the note field
         
     | 
| 
       23 
     | 
    
         
            -
                attr_accessor :name
         
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
                ##
         
     | 
| 
       26 
     | 
    
         
            -
                # A boolean that indicates if this field is sticky when adding cards of the note type in Anki
         
     | 
| 
       27 
     | 
    
         
            -
                attr_accessor :sticky
         
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
                ##
         
     | 
| 
       30 
     | 
    
         
            -
                # A boolean that indicates if this field should be right to left
         
     | 
| 
       31 
     | 
    
         
            -
                attr_accessor :right_to_left
         
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
                ##
         
     | 
| 
       34 
     | 
    
         
            -
                # The font style used when editing the note field
         
     | 
| 
       35 
     | 
    
         
            -
                attr_accessor :font_style
         
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
                ##
         
     | 
| 
       38 
     | 
    
         
            -
                # The font size used when editing the note field
         
     | 
| 
       39 
     | 
    
         
            -
                attr_accessor :font_size
         
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
       41 
     | 
    
         
            -
                ##
         
     | 
| 
       42 
     | 
    
         
            -
                # The description of the note field
         
     | 
| 
       43 
     | 
    
         
            -
                attr_accessor :description
         
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
                ##
         
     | 
| 
       46 
     | 
    
         
            -
                # 0 for the first field of the note type, 1 for the second, etc.
         
     | 
| 
       47 
     | 
    
         
            -
                attr_reader :ordinal_number
         
     | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
       49 
     | 
    
         
            -
                ##
         
     | 
| 
       50 
     | 
    
         
            -
                # Instantiates a new field for the given note type
         
     | 
| 
       51 
     | 
    
         
            -
                def initialize(note_type:, name: nil, args: nil)
         
     | 
| 
       52 
     | 
    
         
            -
                  raise ArgumentError unless (name && args.nil?) || (args && args["name"])
         
     | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
       54 
     | 
    
         
            -
                  @note_type = note_type
         
     | 
| 
       55 
     | 
    
         
            -
                  if args
         
     | 
| 
       56 
     | 
    
         
            -
                    setup_note_field_instance_variables_from_existing(args: args)
         
     | 
| 
       57 
     | 
    
         
            -
                  else
         
     | 
| 
       58 
     | 
    
         
            -
                    setup_note_field_instance_variables(name: name)
         
     | 
| 
       59 
     | 
    
         
            -
                  end
         
     | 
| 
       60 
     | 
    
         
            -
                end
         
     | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
       62 
     | 
    
         
            -
                private
         
     | 
| 
       63 
     | 
    
         
            -
             
     | 
| 
       64 
     | 
    
         
            -
                  def setup_note_field_instance_variables_from_existing(args:)
         
     | 
| 
       65 
     | 
    
         
            -
                    @name = args["name"]
         
     | 
| 
       66 
     | 
    
         
            -
                    @ordinal_number = args["ord"]
         
     | 
| 
       67 
     | 
    
         
            -
                    @sticky = args["sticky"]
         
     | 
| 
       68 
     | 
    
         
            -
                    @right_to_left = args["rtl"]
         
     | 
| 
       69 
     | 
    
         
            -
                    @font_style = args["font"]
         
     | 
| 
       70 
     | 
    
         
            -
                    @font_size = args["size"]
         
     | 
| 
       71 
     | 
    
         
            -
                    @description = args["description"]
         
     | 
| 
       72 
     | 
    
         
            -
                  end
         
     | 
| 
       73 
     | 
    
         
            -
             
     | 
| 
       74 
     | 
    
         
            -
                  def setup_note_field_instance_variables(name:)
         
     | 
| 
       75 
     | 
    
         
            -
                    @name = name
         
     | 
| 
       76 
     | 
    
         
            -
                    @ordinal_number = @note_type.fields.length
         
     | 
| 
       77 
     | 
    
         
            -
                    @sticky = false
         
     | 
| 
       78 
     | 
    
         
            -
                    @right_to_left = false
         
     | 
| 
       79 
     | 
    
         
            -
                    @font_style = DEFAULT_FIELD_FONT_STYLE
         
     | 
| 
       80 
     | 
    
         
            -
                    @font_size = DEFAULT_FIELD_FONT_SIZE
         
     | 
| 
       81 
     | 
    
         
            -
                    @description = DEFAULT_FIELD_DESCRIPTION
         
     | 
| 
       82 
     | 
    
         
            -
                  end
         
     | 
| 
       83 
     | 
    
         
            -
              end
         
     | 
| 
       84 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,233 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # frozen_string_literal: true
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            require "pry"
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
            require_relative "card_template"
         
     | 
| 
       6 
     | 
    
         
            -
            require_relative "helpers/shared_constants_helper"
         
     | 
| 
       7 
     | 
    
         
            -
            require_relative "helpers/time_helper"
         
     | 
| 
       8 
     | 
    
         
            -
            require_relative "note_field"
         
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
            module AnkiRecord
         
     | 
| 
       11 
     | 
    
         
            -
              ##
         
     | 
| 
       12 
     | 
    
         
            -
              # NoteType represents an Anki note type (also called a model)
         
     | 
| 
       13 
     | 
    
         
            -
              class NoteType
         
     | 
| 
       14 
     | 
    
         
            -
                include AnkiRecord::SharedConstantsHelper
         
     | 
| 
       15 
     | 
    
         
            -
                include AnkiRecord::TimeHelper
         
     | 
| 
       16 
     | 
    
         
            -
                NEW_NOTE_TYPE_SORT_FIELD = 0
         
     | 
| 
       17 
     | 
    
         
            -
                private_constant :NEW_NOTE_TYPE_SORT_FIELD
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
                ##
         
     | 
| 
       20 
     | 
    
         
            -
                # The collection object that the note type belongs to
         
     | 
| 
       21 
     | 
    
         
            -
                attr_reader :collection
         
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
                ##
         
     | 
| 
       24 
     | 
    
         
            -
                # The id of the note type
         
     | 
| 
       25 
     | 
    
         
            -
                attr_reader :id
         
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
                ##
         
     | 
| 
       28 
     | 
    
         
            -
                # The name of the note type
         
     | 
| 
       29 
     | 
    
         
            -
                attr_accessor :name
         
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
                ##
         
     | 
| 
       32 
     | 
    
         
            -
                # A boolean that indicates if this note type is a cloze-deletion note type
         
     | 
| 
       33 
     | 
    
         
            -
                attr_accessor :cloze
         
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
                ##
         
     | 
| 
       36 
     | 
    
         
            -
                # The CSS styling of the note type
         
     | 
| 
       37 
     | 
    
         
            -
                attr_reader :css
         
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
                ##
         
     | 
| 
       40 
     | 
    
         
            -
                # The LaTeX preamble of the note type
         
     | 
| 
       41 
     | 
    
         
            -
                attr_reader :latex_preamble
         
     | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
     | 
    
         
            -
                ##
         
     | 
| 
       44 
     | 
    
         
            -
                # The LaTeX postamble of the note type
         
     | 
| 
       45 
     | 
    
         
            -
                attr_reader :latex_postamble
         
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
       47 
     | 
    
         
            -
                ##
         
     | 
| 
       48 
     | 
    
         
            -
                # A boolean probably related to something with LaTeX and SVG.
         
     | 
| 
       49 
     | 
    
         
            -
                #
         
     | 
| 
       50 
     | 
    
         
            -
                # TODO: Investigate what this does
         
     | 
| 
       51 
     | 
    
         
            -
                attr_reader :latex_svg
         
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
       53 
     | 
    
         
            -
                ##
         
     | 
| 
       54 
     | 
    
         
            -
                # An array of the card template objects belonging to the note type
         
     | 
| 
       55 
     | 
    
         
            -
                attr_reader :card_templates
         
     | 
| 
       56 
     | 
    
         
            -
             
     | 
| 
       57 
     | 
    
         
            -
                ##
         
     | 
| 
       58 
     | 
    
         
            -
                # An array of the field names of the card template
         
     | 
| 
       59 
     | 
    
         
            -
                attr_reader :fields
         
     | 
| 
       60 
     | 
    
         
            -
             
     | 
| 
       61 
     | 
    
         
            -
                ##
         
     | 
| 
       62 
     | 
    
         
            -
                # TODO: Investigate the meaning of the deck id of a note type
         
     | 
| 
       63 
     | 
    
         
            -
                attr_reader :deck_id
         
     | 
| 
       64 
     | 
    
         
            -
             
     | 
| 
       65 
     | 
    
         
            -
                ##
         
     | 
| 
       66 
     | 
    
         
            -
                # TODO: Investigate the meaning of tags of a note type
         
     | 
| 
       67 
     | 
    
         
            -
                attr_reader :tags
         
     | 
| 
       68 
     | 
    
         
            -
             
     | 
| 
       69 
     | 
    
         
            -
                ##
         
     | 
| 
       70 
     | 
    
         
            -
                # Instantiates a new note type
         
     | 
| 
       71 
     | 
    
         
            -
                def initialize(collection:, name: nil, cloze: false, args: nil)
         
     | 
| 
       72 
     | 
    
         
            -
                  raise ArgumentError unless (name && args.nil?) || (args && args["name"])
         
     | 
| 
       73 
     | 
    
         
            -
             
     | 
| 
       74 
     | 
    
         
            -
                  @collection = collection
         
     | 
| 
       75 
     | 
    
         
            -
             
     | 
| 
       76 
     | 
    
         
            -
                  if args
         
     | 
| 
       77 
     | 
    
         
            -
                    setup_note_type_instance_variables_from_existing(args: args)
         
     | 
| 
       78 
     | 
    
         
            -
                  else
         
     | 
| 
       79 
     | 
    
         
            -
                    setup_note_type_instance_variables(name: name, cloze: cloze)
         
     | 
| 
       80 
     | 
    
         
            -
                  end
         
     | 
| 
       81 
     | 
    
         
            -
                end
         
     | 
| 
       82 
     | 
    
         
            -
             
     | 
| 
       83 
     | 
    
         
            -
                ##
         
     | 
| 
       84 
     | 
    
         
            -
                # Creates a new field and adds it to this note type's fields
         
     | 
| 
       85 
     | 
    
         
            -
                #
         
     | 
| 
       86 
     | 
    
         
            -
                # The field is an instance of AnkiRecord::NoteField
         
     | 
| 
       87 
     | 
    
         
            -
                def new_note_field(name:)
         
     | 
| 
       88 
     | 
    
         
            -
                  # TODO: Raise an exception if the name is already used by a field in this note type
         
     | 
| 
       89 
     | 
    
         
            -
                  note_field = AnkiRecord::NoteField.new(note_type: self, name: name)
         
     | 
| 
       90 
     | 
    
         
            -
                  @fields << note_field
         
     | 
| 
       91 
     | 
    
         
            -
                  note_field
         
     | 
| 
       92 
     | 
    
         
            -
                end
         
     | 
| 
       93 
     | 
    
         
            -
             
     | 
| 
       94 
     | 
    
         
            -
                ##
         
     | 
| 
       95 
     | 
    
         
            -
                # Create a new card template and adds it to this note type's templates
         
     | 
| 
       96 
     | 
    
         
            -
                #
         
     | 
| 
       97 
     | 
    
         
            -
                # The card template is an instance of AnkiRecord::CardTemplate
         
     | 
| 
       98 
     | 
    
         
            -
                def new_card_template(name:)
         
     | 
| 
       99 
     | 
    
         
            -
                  # TODO: Raise an exception if the name is already used by a template in this note type
         
     | 
| 
       100 
     | 
    
         
            -
                  card_template = AnkiRecord::CardTemplate.new(note_type: self, name: name)
         
     | 
| 
       101 
     | 
    
         
            -
                  @card_templates << card_template
         
     | 
| 
       102 
     | 
    
         
            -
                  card_template
         
     | 
| 
       103 
     | 
    
         
            -
                end
         
     | 
| 
       104 
     | 
    
         
            -
             
     | 
| 
       105 
     | 
    
         
            -
                ##
         
     | 
| 
       106 
     | 
    
         
            -
                # Find one of the note type's card templates by name
         
     | 
| 
       107 
     | 
    
         
            -
                def find_card_template_by(name:)
         
     | 
| 
       108 
     | 
    
         
            -
                  card_templates.find { |template| template.name == name }
         
     | 
| 
       109 
     | 
    
         
            -
                end
         
     | 
| 
       110 
     | 
    
         
            -
             
     | 
| 
       111 
     | 
    
         
            -
                ##
         
     | 
| 
       112 
     | 
    
         
            -
                # The field names of the note type ordered by their ordinal values
         
     | 
| 
       113 
     | 
    
         
            -
                def field_names_in_order
         
     | 
| 
       114 
     | 
    
         
            -
                  @fields.sort_by(&:ordinal_number).map(&:name)
         
     | 
| 
       115 
     | 
    
         
            -
                end
         
     | 
| 
       116 
     | 
    
         
            -
             
     | 
| 
       117 
     | 
    
         
            -
                ##
         
     | 
| 
       118 
     | 
    
         
            -
                # The allowed field names of the note in snake_case
         
     | 
| 
       119 
     | 
    
         
            -
                #
         
     | 
| 
       120 
     | 
    
         
            -
                # TODO: make this more robust... what happens when the note type name has non-alphabetic characters?
         
     | 
| 
       121 
     | 
    
         
            -
                def snake_case_field_names
         
     | 
| 
       122 
     | 
    
         
            -
                  field_names_in_order.map { |field_name| field_name.downcase.gsub(" ", "_") }
         
     | 
| 
       123 
     | 
    
         
            -
                end
         
     | 
| 
       124 
     | 
    
         
            -
             
     | 
| 
       125 
     | 
    
         
            -
                ##
         
     | 
| 
       126 
     | 
    
         
            -
                # The name of the field used to sort notes of the note type in the Anki browser
         
     | 
| 
       127 
     | 
    
         
            -
                def sort_field_name
         
     | 
| 
       128 
     | 
    
         
            -
                  @fields.find { |field| field.ordinal_number == @sort_field }&.name
         
     | 
| 
       129 
     | 
    
         
            -
                end
         
     | 
| 
       130 
     | 
    
         
            -
             
     | 
| 
       131 
     | 
    
         
            -
                ##
         
     | 
| 
       132 
     | 
    
         
            -
                # The name of the sort field in snake_case
         
     | 
| 
       133 
     | 
    
         
            -
                def snake_case_sort_field_name
         
     | 
| 
       134 
     | 
    
         
            -
                  sort_field_name.downcase.gsub(" ", "_")
         
     | 
| 
       135 
     | 
    
         
            -
                end
         
     | 
| 
       136 
     | 
    
         
            -
             
     | 
| 
       137 
     | 
    
         
            -
                ##
         
     | 
| 
       138 
     | 
    
         
            -
                # The allowed field_name values in {{field_name}} of the note type's card templates' question format
         
     | 
| 
       139 
     | 
    
         
            -
                #
         
     | 
| 
       140 
     | 
    
         
            -
                # These are the note type's fields' names, and if the note type is a cloze type,
         
     | 
| 
       141 
     | 
    
         
            -
                # these also include the note type's fields' names prepended with 'cloze:'.
         
     | 
| 
       142 
     | 
    
         
            -
                #
         
     | 
| 
       143 
     | 
    
         
            -
                # TODO: research if other special field names like e.g. 'FrontSide' are allowed
         
     | 
| 
       144 
     | 
    
         
            -
                def allowed_card_template_question_format_field_names
         
     | 
| 
       145 
     | 
    
         
            -
                  allowed = field_names_in_order
         
     | 
| 
       146 
     | 
    
         
            -
                  cloze ? allowed + field_names_in_order.map { |field_name| "cloze:#{field_name}" } : allowed
         
     | 
| 
       147 
     | 
    
         
            -
                end
         
     | 
| 
       148 
     | 
    
         
            -
             
     | 
| 
       149 
     | 
    
         
            -
                ##
         
     | 
| 
       150 
     | 
    
         
            -
                # The allowed field_name values in {{field_name}} of the note type's card templates' answer format
         
     | 
| 
       151 
     | 
    
         
            -
                #
         
     | 
| 
       152 
     | 
    
         
            -
                # These are the note type's fields' names, and if the note type is a cloze type,
         
     | 
| 
       153 
     | 
    
         
            -
                # these also include the note type's fields' names prepended with 'cloze:'.
         
     | 
| 
       154 
     | 
    
         
            -
                #
         
     | 
| 
       155 
     | 
    
         
            -
                # TODO: research if other special field names like e.g. 'FrontSide' are allowed
         
     | 
| 
       156 
     | 
    
         
            -
                def allowed_card_template_answer_format_field_names
         
     | 
| 
       157 
     | 
    
         
            -
                  allowed_card_template_question_format_field_names + ["FrontSide"]
         
     | 
| 
       158 
     | 
    
         
            -
                end
         
     | 
| 
       159 
     | 
    
         
            -
             
     | 
| 
       160 
     | 
    
         
            -
                private
         
     | 
| 
       161 
     | 
    
         
            -
             
     | 
| 
       162 
     | 
    
         
            -
                  # rubocop:disable Metrics/MethodLength
         
     | 
| 
       163 
     | 
    
         
            -
                  # rubocop:disable Metrics/AbcSize
         
     | 
| 
       164 
     | 
    
         
            -
                  def setup_note_type_instance_variables_from_existing(args:)
         
     | 
| 
       165 
     | 
    
         
            -
                    @id = args["id"]
         
     | 
| 
       166 
     | 
    
         
            -
                    @name = args["name"]
         
     | 
| 
       167 
     | 
    
         
            -
                    @cloze = args["type"] == 1
         
     | 
| 
       168 
     | 
    
         
            -
                    @last_modified_time = args["mod"]
         
     | 
| 
       169 
     | 
    
         
            -
                    @usn = args["usn"]
         
     | 
| 
       170 
     | 
    
         
            -
                    @sort_field = args["sortf"]
         
     | 
| 
       171 
     | 
    
         
            -
                    @deck_id = args["did"]
         
     | 
| 
       172 
     | 
    
         
            -
                    @fields = args["flds"].map { |fld| NoteField.new(note_type: self, args: fld) }
         
     | 
| 
       173 
     | 
    
         
            -
                    @card_templates = args["tmpls"].map { |tmpl| CardTemplate.new(note_type: self, args: tmpl) }
         
     | 
| 
       174 
     | 
    
         
            -
                    @css = args["css"]
         
     | 
| 
       175 
     | 
    
         
            -
                    @latex_preamble = args["latexPre"]
         
     | 
| 
       176 
     | 
    
         
            -
                    @latex_postamble = args["latexPost"]
         
     | 
| 
       177 
     | 
    
         
            -
                    @latex_svg = args["latexsvg"]
         
     | 
| 
       178 
     | 
    
         
            -
                    @req = args["req"]
         
     | 
| 
       179 
     | 
    
         
            -
                    @tags = args["tags"]
         
     | 
| 
       180 
     | 
    
         
            -
                    @vers = args["vers"]
         
     | 
| 
       181 
     | 
    
         
            -
                  end
         
     | 
| 
       182 
     | 
    
         
            -
                  # rubocop:enable Metrics/MethodLength
         
     | 
| 
       183 
     | 
    
         
            -
                  # rubocop:enable Metrics/AbcSize
         
     | 
| 
       184 
     | 
    
         
            -
             
     | 
| 
       185 
     | 
    
         
            -
                  # rubocop:disable Metrics/MethodLength
         
     | 
| 
       186 
     | 
    
         
            -
                  def setup_note_type_instance_variables(name:, cloze:)
         
     | 
| 
       187 
     | 
    
         
            -
                    @id = milliseconds_since_epoch
         
     | 
| 
       188 
     | 
    
         
            -
                    @name = name
         
     | 
| 
       189 
     | 
    
         
            -
                    @cloze = cloze
         
     | 
| 
       190 
     | 
    
         
            -
                    @last_modified_time = seconds_since_epoch
         
     | 
| 
       191 
     | 
    
         
            -
                    @usn = NEW_OBJECT_USN
         
     | 
| 
       192 
     | 
    
         
            -
                    @sort_field = NEW_NOTE_TYPE_SORT_FIELD
         
     | 
| 
       193 
     | 
    
         
            -
                    @deck_id = nil
         
     | 
| 
       194 
     | 
    
         
            -
                    @fields = []
         
     | 
| 
       195 
     | 
    
         
            -
                    @card_templates = []
         
     | 
| 
       196 
     | 
    
         
            -
                    @css = default_css
         
     | 
| 
       197 
     | 
    
         
            -
                    @latex_preamble = default_latex_preamble
         
     | 
| 
       198 
     | 
    
         
            -
                    @latex_postamble = default_latex_postamble
         
     | 
| 
       199 
     | 
    
         
            -
                    @latex_svg = false
         
     | 
| 
       200 
     | 
    
         
            -
                    @req = nil
         
     | 
| 
       201 
     | 
    
         
            -
                    @tags = []
         
     | 
| 
       202 
     | 
    
         
            -
                    @vers = []
         
     | 
| 
       203 
     | 
    
         
            -
                  end
         
     | 
| 
       204 
     | 
    
         
            -
                  # rubocop:enable Metrics/MethodLength
         
     | 
| 
       205 
     | 
    
         
            -
             
     | 
| 
       206 
     | 
    
         
            -
                  def default_css
         
     | 
| 
       207 
     | 
    
         
            -
                    <<-CSS
         
     | 
| 
       208 
     | 
    
         
            -
                    .card {
         
     | 
| 
       209 
     | 
    
         
            -
                      color: black;
         
     | 
| 
       210 
     | 
    
         
            -
                      background-color: transparent;
         
     | 
| 
       211 
     | 
    
         
            -
                      text-align: center;
         
     | 
| 
       212 
     | 
    
         
            -
                    }
         
     | 
| 
       213 
     | 
    
         
            -
                    CSS
         
     | 
| 
       214 
     | 
    
         
            -
                  end
         
     | 
| 
       215 
     | 
    
         
            -
             
     | 
| 
       216 
     | 
    
         
            -
                  def default_latex_preamble
         
     | 
| 
       217 
     | 
    
         
            -
                    <<-LATEX_PRE
         
     | 
| 
       218 
     | 
    
         
            -
                    \\documentclass[12pt]{article}
         
     | 
| 
       219 
     | 
    
         
            -
                    \\special{papersize=3in,5in}
         
     | 
| 
       220 
     | 
    
         
            -
                    \\usepackage{amssymb,amsmath}
         
     | 
| 
       221 
     | 
    
         
            -
                    \\pagestyle{empty}
         
     | 
| 
       222 
     | 
    
         
            -
                    \\setlength{\\parindent}{0in}
         
     | 
| 
       223 
     | 
    
         
            -
                    \\begin{document}
         
     | 
| 
       224 
     | 
    
         
            -
                    LATEX_PRE
         
     | 
| 
       225 
     | 
    
         
            -
                  end
         
     | 
| 
       226 
     | 
    
         
            -
             
     | 
| 
       227 
     | 
    
         
            -
                  def default_latex_postamble
         
     | 
| 
       228 
     | 
    
         
            -
                    <<-LATEX_POST
         
     | 
| 
       229 
     | 
    
         
            -
                    \\end{document}
         
     | 
| 
       230 
     | 
    
         
            -
                    LATEX_POST
         
     | 
| 
       231 
     | 
    
         
            -
                  end
         
     | 
| 
       232 
     | 
    
         
            -
              end
         
     | 
| 
       233 
     | 
    
         
            -
            end
         
     |