Sha256: 521cce37305a67c9b38d7a2d1527d7dd026e0fc988475b523f79584b11c65c42
Contents?: true
Size: 815 Bytes
Versions: 11
Compression:
Stored size: 815 Bytes
Contents
# frozen_string_literal: true module Alchemy module Ingredients # A text headline # class Headline < Alchemy::Ingredient include DomIds store_accessor :data, :dom_id, :level, :size before_create :set_level_and_size def preview_text(maxlength = 30) "H#{level}: #{value}"[0..maxlength - 1] end def level_options levels.map { |level| ["H#{level}", level] } end def size_options sizes.map { |size| [".h#{size}", size] } end private def levels settings.fetch(:levels, (1..6)) end def sizes settings.fetch(:sizes, []) end def set_level_and_size self.level ||= levels.first self.size ||= sizes.first end end end end
Version data entries
11 entries across 11 versions & 1 rubygems