Class: Caracal::Core::Models::TableOfContentsModel

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/caracal/core/models/table_of_contents_model.rb

Overview

This class encapsulates the logic needed to store and manipulate text data.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}, &block) ⇒ TableOfContentsModel

initialization



32
33
34
35
36
37
# File 'lib/caracal/core/models/table_of_contents_model.rb', line 32

def initialize(options={}, &block)
  @toc_opts  ||= DEFAULT_OPTS
  @toc_size  ||= DEFAULT_SIZE
  @toc_title ||= DEFAULT_TITLE
  super options, &block
end

Instance Attribute Details

#toc_optsObject (readonly)

accessors



23
24
25
# File 'lib/caracal/core/models/table_of_contents_model.rb', line 23

def toc_opts
  @toc_opts
end

#toc_sizeObject (readonly)

Returns the value of attribute toc_size.



24
25
26
# File 'lib/caracal/core/models/table_of_contents_model.rb', line 24

def toc_size
  @toc_size
end

#toc_titleObject (readonly)

Returns the value of attribute toc_title.



25
26
27
# File 'lib/caracal/core/models/table_of_contents_model.rb', line 25

def toc_title
  @toc_title
end

Instance Method Details

#valid?Boolean

VALIDATION ============================

Returns:

  • (Boolean)


65
66
67
68
# File 'lib/caracal/core/models/table_of_contents_model.rb', line 65

def valid?
  a = [:opts, :size, :title]
  a.map { |m| send("toc_#{ m }") }.compact.size == a.size
end