class Caracal::Core::Models::TableOfContentModel

This class encapsulates the logic needed to store and manipulate table of contents data.

Attributes

toc_end_level[R]
toc_start_level[R]

accessors

Public Class Methods

new(options={}, &block) click to toggle source

initialization

Calls superclass method Caracal::Core::Models::BaseModel::new
# File lib/caracal/core/models/table_of_content_model.rb, line 26
def initialize(options={}, &block)
  @toc_start_level = DEFAULT_START_LEVEL
  @toc_end_level = DEFAULT_END_LEVEL

  super options, &block
end

Public Instance Methods

includes?(level) click to toggle source
STATE HELPER ===========================
# File lib/caracal/core/models/table_of_content_model.rb, line 48
def includes?(level)
  (toc_start_level..toc_end_level).include? level
end
valid?() click to toggle source
VALIDATION ============================
# File lib/caracal/core/models/table_of_content_model.rb, line 54
def valid?
  [:start_level, :end_level].each do |method|
    value = send("toc_#{method}")
    return false if value <= 0 || value > 6

  end
  toc_start_level <= toc_end_level
end

Private Instance Methods

option_keys() click to toggle source
# File lib/caracal/core/models/table_of_content_model.rb, line 69
def option_keys
  [:start_level, :end_level]
end