Class: CKEditor5::Rails::Presets::SpecialCharactersBuilder::Group
- Inherits:
-
Object
- Object
- CKEditor5::Rails::Presets::SpecialCharactersBuilder::Group
- Defined in:
- lib/ckeditor5/rails/presets/special_characters_builder.rb
Overview
Builder class for configuring special characters groups
Instance Attribute Summary collapse
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#add_characters(items) ⇒ Object
Add multiple characters to the group.
-
#add_items(collection) ⇒ Object
Add multiple characters to the group at once.
-
#initialize(name, label: nil) ⇒ Group
constructor
Initialize a new special characters group.
-
#item(title, character) ⇒ Object
Add a single character to the group.
-
#to_h ⇒ Hash
Convert group configuration to hash.
Constructor Details
#initialize(name, label: nil) ⇒ Group
Initialize a new special characters group
30 31 32 33 34 |
# File 'lib/ckeditor5/rails/presets/special_characters_builder.rb', line 30 def initialize(name, label: nil) @name = name @label = label @items = [] end |
Instance Attribute Details
#label ⇒ Object (readonly)
Returns the value of attribute label.
23 24 25 |
# File 'lib/ckeditor5/rails/presets/special_characters_builder.rb', line 23 def label @label end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
23 24 25 |
# File 'lib/ckeditor5/rails/presets/special_characters_builder.rb', line 23 def name @name end |
Instance Method Details
#add_characters(items) ⇒ Object
Add multiple characters to the group
63 64 65 66 67 |
# File 'lib/ckeditor5/rails/presets/special_characters_builder.rb', line 63 def add_characters(items) items.each do |item| @items << item.slice(:title, :character) end end |
#add_items(collection) ⇒ Object
Add multiple characters to the group at once
54 55 56 57 58 |
# File 'lib/ckeditor5/rails/presets/special_characters_builder.rb', line 54 def add_items(collection) collection.each do |item| @items << item.slice(:title, :character) end end |
#item(title, character) ⇒ Object
Add a single character to the group
42 43 44 |
# File 'lib/ckeditor5/rails/presets/special_characters_builder.rb', line 42 def item(title, character) @items << { title: title, character: character } end |
#to_h ⇒ Hash
Convert group configuration to hash
72 73 74 75 76 77 78 |
# File 'lib/ckeditor5/rails/presets/special_characters_builder.rb', line 72 def to_h { name: @name, items: @items, options: label ? { label: label } : {} } end |