Class: AnkiRecord::NoteField
- Inherits:
-
Object
- Object
- AnkiRecord::NoteField
- Includes:
- NoteFieldAttributes, NoteFieldDefaults
- Defined in:
- lib/anki_record/note_field/note_field.rb
Overview
NoteField represents a field of an Anki note type
Instance Attribute Summary
Attributes included from NoteFieldAttributes
#description, #font_size, #font_style, #name, #note_type, #ordinal_number, #right_to_left, #sticky
Instance Method Summary collapse
-
#initialize(note_type:, name: nil, args: nil) ⇒ NoteField
constructor
Instantiates a new field for the note type
note_type
with namename
. -
#to_h ⇒ Object
:nodoc:.
Constructor Details
#initialize(note_type:, name: nil, args: nil) ⇒ NoteField
Instantiates a new field for the note type note_type
with name name
.
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/anki_record/note_field/note_field.rb', line 15 def initialize(note_type:, name: nil, args: nil) raise ArgumentError unless (name && args.nil?) || (args && args["name"]) @note_type = note_type if args setup_note_field_instance_variables_from_existing(args:) else setup_note_field_instance_variables_for_new_field(name:) end @note_type.add_note_field self end |
Instance Method Details
#to_h ⇒ Object
:nodoc:
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/anki_record/note_field/note_field.rb', line 28 def to_h # :nodoc: { name: @name, ord: @ordinal_number, sticky: @sticky, rtl: @right_to_left, font: @font_style, size: @font_size, description: @description } end |